in oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreService.java [324:591]
private static SegmentNodeStore registerSegmentStore(
ComponentContext context,
Configuration configuration,
BlobStore blobStore,
SegmentNodeStorePersistence segmentStore,
PersistentCache persistentCache,
StatisticsProvider statisticsProvider,
Closer closer,
Whiteboard whiteboard,
Logger logger
) throws IOException {
return SegmentNodeStoreRegistrar.registerSegmentNodeStore(new SegmentNodeStoreRegistrar.Configuration() {
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 true;
}
@Override
public boolean isSecondarySegmentStore() {
return false;
}
@Override
public boolean isStandbyInstance() {
return configuration.standby();
}
@Override
public String getRole() {
return null;
}
@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(), "segmentstore");
}
@Override
public File getSplitPersistenceDirectory() {
return new File(getRepositoryHome(), "segmentstore-split");
}
@Override
public int getSegmentCacheSize() {
Integer size = Integer.getInteger("segmentCache.size");
if (size != null) {
return size;
}
return configuration.segmentCache_size();
}
@Override
public int getStringCacheSize() {
return getCacheSize("stringCache.size", configuration.stringCache_size());
}
@Override
public int getTemplateCacheSize() {
Integer size = Integer.getInteger("templateCache.size");
if (size != null) {
return size;
}
return configuration.templateCache_size();
}
@Override
public int getStringDeduplicationCacheSize() {
Integer size = Integer.getInteger("stringDeduplicationCache.size");
if (size != null) {
return size;
}
return configuration.stringDeduplicationCache_size();
}
@Override
public int getTemplateDeduplicationCacheSize() {
Integer size = Integer.getInteger("templateDeduplicationCache.size");
if (size != null) {
return size;
}
return configuration.templateDeduplicationCache_size();
}
@Override
public int getNodeDeduplicationCacheSize() {
Integer size = Integer.getInteger("nodeDeduplicationCache.size");
if (size != null) {
return roundToNextPowerOfTwo(size);
}
return roundToNextPowerOfTwo(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 true;
}
@Override
public boolean dispatchChanges() {
return !isStandbyInstance();
}
@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(), "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();
}
});
}