@Override public final void run() { JcrRepository repository = repositoryRef.get(); if (repository != null && repository.getState() == State.RUNNING) { doRun(repository); } }
@Override public final void run() { JcrRepository repository = repositoryRef.get(); if (repository != null && repository.getState() == State.RUNNING) { doRun(repository); } }
/** * Get the state of the deployed {@link Repository} instance with the given the name. * * @param repositoryName the name of the deployed repository * @return the state of the repository instance; never null * @throws IllegalArgumentException if the repository name is null, blank or invalid * @throws NoSuchRepositoryException if there is no repository with the specified name * @throws IllegalStateException if this engine is not {@link #getState() running} * @see #deploy(RepositoryConfiguration) * @see #undeploy(String) */ public final State getRepositoryState( String repositoryName ) throws NoSuchRepositoryException { return getRepository(repositoryName).getState(); }
/** * Get the state of the deployed {@link Repository} instance with the given the name. * * @param repositoryName the name of the deployed repository * @return the state of the repository instance; never null * @throws IllegalArgumentException if the repository name is null, blank or invalid * @throws NoSuchRepositoryException if there is no repository with the specified name * @throws IllegalStateException if this engine is not {@link #getState() running} * @see #deploy(RepositoryConfiguration) * @see #undeploy(String) */ public final State getRepositoryState( String repositoryName ) throws NoSuchRepositoryException { return getRepository(repositoryName).getState(); }
/** * Get an instantaneous snapshot of the JCR repositories and their state. Note that the results are accurate only when this * methods returns. * * @return the immutable map of repository states keyed by repository names; never null */ public Map<String, State> getRepositories() { checkRunning(); Map<String, State> results = new HashMap<String, State>(); final Lock lock = this.lock.readLock(); try { lock.lock(); for (JcrRepository repository : repositories.values()) { results.put(repository.getName(), repository.getState()); } } finally { lock.unlock(); } return Collections.unmodifiableMap(results); }
/** * Get an instantaneous snapshot of the JCR repositories and their state. Note that the results are accurate only when this * methods returns. * * @return the immutable map of repository states keyed by repository names; never null */ public Map<String, State> getRepositories() { checkRunning(); Map<String, State> results = new HashMap<String, State>(); final Lock lock = this.lock.readLock(); try { lock.lock(); for (JcrRepository repository : repositories.values()) { results.put(repository.getName(), repository.getState()); } } finally { lock.unlock(); } return Collections.unmodifiableMap(results); }
lock.lock(); for (JcrRepository repository : repositories.values()) { switch (repository.getState()) { case NOT_RUNNING: case STOPPING:
protected final void prepareToRestore() throws RepositoryException { logger.debug("Preparing to restore '{0}' repository; setting state to RESTORING", getName()); if (getState() == State.RESTORING) { throw new RepositoryException(JcrI18n.repositoryIsCurrentlyBeingRestored.text(getName())); } state.set(State.RESTORING); }
protected final void prepareToRestore() throws RepositoryException { logger.debug("Preparing to restore '{0}' repository; setting state to RESTORING", getName()); if (getState() == State.RESTORING) { throw new RepositoryException(JcrI18n.repositoryIsCurrentlyBeingRestored.text(getName())); } state.set(State.RESTORING); }
@Override @SuppressWarnings( {"unchecked", "rawtypes"} ) public JcrRepository getRepository( String repositoryName, Map parameters ) throws RepositoryException { if (!StringUtil.isBlank(repositoryName)) { try { JcrRepository repository = engine().getRepository(repositoryName); if (repository.getState() == ModeShapeEngine.State.STARTING || repository.getState() == ModeShapeEngine.State.RUNNING) { return repository; } } catch (NoSuchRepositoryException e) { // there is no such repository, so try to create & initialize it } } String repositoryURL = repositoryURLFromParams(parameters); if (StringUtil.isBlank(repositoryURL)) { LOG.debug("No repository URL parameter found"); return null; } Map configParams = parameters; if (!StringUtil.isBlank(repositoryName)) { configParams = new HashMap(parameters); configParams.put(RepositoryFactory.REPOSITORY_NAME, repositoryName); } if (repositoryURL.toLowerCase().startsWith(JNDI_PROTOCOL)) { return new JNDIRepositoryLookup().repository(configParams, repositoryURL); } return new UrlRepositoryLookup().repository(configParams, repositoryURL); }
if (repository.getState() == State.RUNNING) { return ImmediateFuture.create(repository);
if (repository.getState() == State.RUNNING) { return ImmediateFuture.create(repository);
switch (repository.getState()) { case STARTING: case RUNNING:
@Override @SuppressWarnings( {"unchecked", "rawtypes"} ) public JcrRepository getRepository( String repositoryName, Map parameters ) throws RepositoryException { if (!StringUtil.isBlank(repositoryName)) { try { JcrRepository repository = engine().getRepository(repositoryName); if (repository.getState() == ModeShapeEngine.State.STARTING || repository.getState() == ModeShapeEngine.State.RUNNING) { return repository; } } catch (NoSuchRepositoryException e) { // there is no such repository, so try to create & initialize it } } String repositoryURL = repositoryURLFromParams(parameters); if (StringUtil.isBlank(repositoryURL)) { LOG.debug("No repository URL parameter found"); return null; } Map configParams = parameters; if (!StringUtil.isBlank(repositoryName)) { configParams = new HashMap(parameters); configParams.put(RepositoryFactory.REPOSITORY_NAME, repositoryName); } if (repositoryURL.toLowerCase().startsWith(JNDI_PROTOCOL)) { return new JNDIRepositoryLookup().repository(configParams, repositoryURL); } return new UrlRepositoryLookup().repository(configParams, repositoryURL); }
switch (repository.getState()) { case STARTING: case RUNNING:
@Test public void shouldAutomaticallyStartRepositoryUponLogin() throws Exception { engine.start(); JcrRepository repository = engine.deploy(config); String name = repository.getName(); assertThat(engine.getRepositoryState(name), is(State.NOT_RUNNING)); assertThat(repository.getState(), is(State.NOT_RUNNING)); for (int i = 0; i != 4; ++i) { javax.jcr.Session session = repository.login(); assertThat(repository.getState(), is(State.RUNNING)); session.logout(); } assertThat(engine.getRepositoryState(name), is(State.RUNNING)); engine.shutdownRepository(name).get(); // blocks assertThat(engine.getRepositoryState(name), is(State.NOT_RUNNING)); }
public static void killRepository( JcrRepository repository ) { if (repository == null || repository.getState() != State.RUNNING) return; try { // Rollback any open transactions ... killTransaction(repository.runningState().txnManager()); // First shut down the repository ... repository.doShutdown(false); } catch (Throwable t) { log.error(t, JcrI18n.errorKillingRepository, repository.getName(), t.getMessage()); } }
String name = repository.getName(); assertThat(engine.getRepositoryState(name), is(State.NOT_RUNNING)); assertThat(repository.getState(), is(State.NOT_RUNNING));
protected final void completeRestore(RestoreOptions options) throws ExecutionException, Exception { if (getState() == State.RESTORING) { logger.debug("Shutting down '{0}' after content has been restored", getName()); doShutdown(false); logger.debug("Starting '{0}' after content has been restored", getName()); start(); logger.debug("Started '{0}' after content has been restored; beginning indexing of content", getName()); if (options.reindexContentOnFinish()) { // Reindex all content ... queryManager().cleanAndReindex(false); logger.debug("Completed reindexing all content in '{0}' after restore.", getName()); } } }
protected final void completeRestore(RestoreOptions options) throws ExecutionException, Exception { if (getState() == State.RESTORING) { logger.debug("Shutting down '{0}' after content has been restored", getName()); doShutdown(false); logger.debug("Starting '{0}' after content has been restored", getName()); start(); logger.debug("Started '{0}' after content has been restored; beginning indexing of content", getName()); if (options.reindexContentOnFinish()) { // Reindex all content ... queryManager().cleanAndReindex(false); logger.debug("Completed reindexing all content in '{0}' after restore.", getName()); } } }