/** Stop all {@link ReplicatorNode}s. */ protected void stopReplicators() { if (replicatorNodes != null) { synchronized (replicatorNodes) { for (ReplicatorNode replicator : replicatorNodes.values()) { replicator.stop(); } } } }
/** * Initializes the search manager of this workspace info. This method is called while still * holding the write lock on this workspace info, but {@link #initialized} is already set to * <code>true</code>. * * @throws RepositoryException if the search manager could not be created */ @Override protected void doPostInitialize() throws RepositoryException { super.doPostInitialize(); ReplicationConfig rc = ReplicationConfig.create(getRepositoryConfig().getHomeDir()); if (rc == null) { // This is normal. It just means that no replicators are configured. log.debug("No replication config found."); return; } if (rc.getReplicatorConfigs().size() == 0) { log.warn("No replicator nodes configured in replicator config"); return; } if (journal == null) { try { journal = rc.getJournalConfig(); journal.setRepositoryHome(new File(getRepositoryConfig().getHomeDir())); journal.init("REPL-JOURNAL", new RegistryNamespaceResolver(getNamespaceRegistry())); } catch (JournalException e) { log.error("Error while setting up journal for replication. Replication is disabled", e); return; } } if (listener == null) { listener = new ReplicationJournalProducer( getName(), journal.getProducer("REPL-PRODUCER"), journal.getLocalChangesOnly()); } if (replicatorNodes == null) { replicatorNodes = new HashMap<String, ReplicatorNode>(); } for (ReplicatorNodeConfig config : rc.getReplicatorConfigs()) { DefaultNamePathResolver npRes = new DefaultNamePathResolver(getNamespaceRegistry()); HierarchyManager hierMgr = new HierarchyManagerImpl(getRootNodeId(), getItemStateProvider()); ReplicatorContext context = new ReplicatorContext( journal, getItemStateProvider(), getNodeTypeRegistry(), hierMgr, npRes); try { ReplicatorNode replicatorNode = new ReplicatorNode(config); replicatorNode.init(context); replicatorNode.start(); registerReplicator(replicatorNode); } catch (ConfigurationException e) { log.error("Failed to create replicator node", e); } } // register listener ((HippoSharedItemStateManager) getItemStateProvider()).registerUpdateListener(listener); }
/** * Unregister a {@link ReplicatorNode}. * * @param replicator */ public void unRegisterReplicator(ReplicatorNode replicator) { synchronized (replicatorNodes) { replicatorNodes.remove(replicator.getId()); } }
/** * Register a {@link ReplicatorNode}. * * @param replicator */ public void registerReplicator(ReplicatorNode replicator) { synchronized (replicatorNodes) { replicatorNodes.put(replicator.getId(), replicator); } }