in oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactory.java [390:642]
private static SegmentNodeStore registerSegmentStore(
ComponentContext context,
Configuration configuration,
BlobStore blobStore,
SegmentNodeStorePersistence segmentStore,
PersistentCache persistentCache,
StatisticsProvider statisticsProvider,
Closer closer,
Whiteboard whiteboard,
String role,
Logger logger
) throws IOException {
return SegmentNodeStoreRegistrar.registerSegmentNodeStore(new SegmentNodeStoreRegistrar.Configuration() {
String appendRole(String name) {
return name + "-" + role;
}
int roundToNextPowerOfTwo(int size) {
return 1 << (32 - Integer.numberOfLeadingZeros(Math.max(0, size - 1)));
}
String getMode() {
String mode = configuration.tarmk_mode();
if (isNullOrEmpty(mode)) {
return System.getProperty("tarmk.mode", System.getProperty("sun.arch.data.model", "32"));
}
return mode;
}
int getCacheSize(String name, int otherwise) {
Integer size = Integer.getInteger(name);
if (size != null) {
return size;
}
return otherwise;
}
@Override
public boolean isPrimarySegmentStore() {
return false;
}
@Override
public boolean isSecondarySegmentStore() {
return "secondary".equals(role);
}
@Override
public boolean isStandbyInstance() {
return configuration.standby();
}
@Override
public String getRole() {
return role;
}
@Override
public int getRetainedGenerations() {
return configuration.compaction_retainedGenerations();
}
@Override
public int getDefaultRetainedGenerations() {
return RETAINED_GENERATIONS_DEFAULT;
}
@Override
public boolean getPauseCompaction() {
return configuration.pauseCompaction();
}
@Override
public int getRetryCount() {
return configuration.compaction_retryCount();
}
@Override
public int getForceCompactionTimeout() {
return configuration.compaction_force_timeout();
}
@Override
public long getSizeDeltaEstimation() {
return configuration.compaction_sizeDeltaEstimation();
}
@Override
public int getMemoryThreshold() {
return configuration.compaction_memoryThreshold();
}
@Override
public boolean getDisableEstimation() {
return configuration.compaction_disableEstimation();
}
@Override
public long getGCProcessLog() {
return configuration.compaction_progressLog();
}
@Override
public File getSegmentDirectory() {
return new File(getRepositoryHome(), appendRole("segmentstore"));
}
@Override
public File getSplitPersistenceDirectory() {
return new File(getRepositoryHome(), appendRole("segmentstore-split"));
}
@Override
public int getSegmentCacheSize() {
return getCacheSize("segmentCache.size", configuration.segmentCache_size());
}
@Override
public int getStringCacheSize() {
return getCacheSize("stringCache.size", configuration.stringCache_size());
}
@Override
public int getTemplateCacheSize() {
return getCacheSize("templateCache.size", configuration.templateCache_size());
}
@Override
public int getStringDeduplicationCacheSize() {
return getCacheSize("stringDeduplicationCache.size", configuration.stringDeduplicationCache_size());
}
@Override
public int getTemplateDeduplicationCacheSize() {
return getCacheSize("templateDeduplicationCache.size", configuration.templateDeduplicationCache_size());
}
@Override
public int getNodeDeduplicationCacheSize() {
return roundToNextPowerOfTwo(getCacheSize("nodeDeduplicationCache.size", configuration.nodeDeduplicationCache_size()));
}
@Override
public int getMaxFileSize() {
return configuration.tarmk_size();
}
@Override
public boolean getMemoryMapping() {
return getMode().equals("64");
}
@Override
public boolean hasCustomBlobStore() {
return configuration.customBlobStore();
}
@Override
public boolean hasCustomSegmentStore() {
return configuration.customSegmentStore();
}
@Override
public boolean hasSplitPersistence() {
return configuration.splitPersistence();
}
@Override
public boolean hasCachePersistence() {
return configuration.cachePersistence();
}
@Override
public boolean registerDescriptors() {
return configuration.registerDescriptors();
}
@Override
public boolean dispatchChanges() {
return configuration.dispatchChanges();
}
@Override
public String getRepositoryHome() {
String repositoryHome = OsgiUtil.lookupConfigurationThenFramework(context, "repository.home");
if (isNullOrEmpty(repositoryHome)) {
return "repository";
}
return repositoryHome;
}
@Override
public long getBlobSnapshotInterval() {
return configuration.blobTrackSnapshotIntervalInSecs();
}
@Override
public long getBlobGcMaxAge() {
return configuration.blobGcMaxAgeInSecs();
}
@Override
public File getBackupDirectory() {
String backupDirectory = configuration.repository_backup_dir();
if (isNullOrEmpty(backupDirectory)) {
return new File(getRepositoryHome(), appendRole("segmentstore-backup"));
}
return new File(backupDirectory);
}
@Override
public Whiteboard getWhiteboard() {
return whiteboard;
}
@Override
public Closer getCloser() {
return closer;
}
@Override
public Logger getLogger() {
return logger;
}
@Override
public StatisticsProvider getStatisticsProvider() {
return statisticsProvider;
}
@Override
public BlobStore getBlobStore() {
return blobStore;
}
@Override
public SegmentNodeStorePersistence getSegmentNodeStorePersistence() {
return segmentStore;
}
@Override
public PersistentCache getPersistentCache() {
return persistentCache;
}
@Override
public BundleContext getBundleContext() {
return context.getBundleContext();
}
});
}