use of org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter in project jackrabbit-oak by apache.
the class SlowObservationIT method initJcr.
@Override
protected Jcr initJcr(Jcr jcr) {
CommitRateLimiter limiter = new CommitRateLimiter() {
long lastLog;
@Override
public void setDelay(long delay) {
long now = System.currentTimeMillis();
if (now > lastLog + 1000) {
log("Delay " + delay);
lastLog = now;
}
super.setDelay(delay);
}
@Override
protected void delay() throws CommitFailedException {
if (!NO_DELAY_JUST_BLOCK) {
// default behavior
super.delay();
return;
}
if (getBlockCommits() && isThreadBlocking()) {
synchronized (this) {
try {
while (getBlockCommits()) {
wait(1000);
}
} catch (InterruptedException e) {
throw new CommitFailedException(CommitFailedException.OAK, 2, "Interrupted while waiting to commit", e);
}
}
}
}
};
return super.initJcr(jcr).with(limiter);
}
use of org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter in project sling by apache.
the class OakSlingRepositoryManager method activate.
@Activate
private void activate(final OakSlingRepositoryManagerConfiguration configuration, final ComponentContext componentContext) {
this.configuration = configuration;
this.componentContext = componentContext;
final BundleContext bundleContext = componentContext.getBundleContext();
final String defaultWorkspace = configuration.defaultWorkspace();
final boolean disableLoginAdministrative = !configuration.admin_login_enabled();
if (configuration.oak_observation_limitCommitRate()) {
commitRateLimiter = new CommitRateLimiter();
}
this.threadPool = threadPoolManager.get("oak-observation");
this.nodeAggregatorRegistration = bundleContext.registerService(NodeAggregator.class.getName(), getNodeAggregator(), null);
super.start(bundleContext, new Config(defaultWorkspace, disableLoginAdministrative));
}
use of org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter in project jackrabbit-oak by apache.
the class RepositoryManager method activate.
@Activate
public void activate(BundleContext bundleContext, Map<String, ?> config) throws Exception {
observationQueueLength = PropertiesUtil.toInteger(prop(config, bundleContext, OBSERVATION_QUEUE_LENGTH), DEFAULT_OBSERVATION_QUEUE_LENGTH);
if (PropertiesUtil.toBoolean(prop(config, bundleContext, COMMIT_RATE_LIMIT), DEFAULT_COMMIT_RATE_LIMIT)) {
commitRateLimiter = new CommitRateLimiter();
} else {
commitRateLimiter = null;
}
fastQueryResultSize = PropertiesUtil.toBoolean(prop(config, bundleContext, FAST_QUERY_RESULT_SIZE), DEFAULT_FAST_QUERY_RESULT_SIZE);
whiteboard = new OsgiWhiteboard(bundleContext);
initializers = whiteboard.track(RepositoryInitializer.class);
editorProvider.start(whiteboard);
indexEditorProvider.start(whiteboard);
indexProvider.start(whiteboard);
registration = registerRepository(bundleContext);
}
Aggregations