Search in sources :

Example 1 with CommitRateLimiter

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);
}
Also used : CommitRateLimiter(org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

Example 2 with CommitRateLimiter

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));
}
Also used : CommitRateLimiter(org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter) BundleContext(org.osgi.framework.BundleContext) Activate(org.osgi.service.component.annotations.Activate)

Example 3 with CommitRateLimiter

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);
}
Also used : CommitRateLimiter(org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) RepositoryInitializer(org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer) Activate(org.apache.felix.scr.annotations.Activate)

Aggregations

CommitRateLimiter (org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter)3 Activate (org.apache.felix.scr.annotations.Activate)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 OsgiWhiteboard (org.apache.jackrabbit.oak.osgi.OsgiWhiteboard)1 RepositoryInitializer (org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer)1 BundleContext (org.osgi.framework.BundleContext)1 Activate (org.osgi.service.component.annotations.Activate)1