return new ClusterConfig(id, syncDelay, stopDelay, jf);
/** * Initialize this cluster node (overridable). * * @throws ClusterException if an error occurs */ protected void init() throws ClusterException { ClusterConfig cc = clusterContext.getClusterConfig(); clusterNodeId = cc.getId(); syncDelay = cc.getSyncDelay(); stopDelay = cc.getStopDelay(); try { journal = cc.getJournal(clusterContext.getNamespaceResolver()); instanceRevision = journal.getInstanceRevision(); journal.register(this); producer = journal.getProducer(PRODUCER_ID); } catch (RepositoryException e) { throw new ClusterException( "Cluster initialization failed: " + this, e); } catch (JournalException e) { throw new ClusterException( "Journal initialization failed: " + this, e); } }
public void testRepositoryConfigWithSystemVariables() throws Exception { final String id = "testvalue"; final long syncDelay = 11; System.setProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID, id); System.setProperty("cluster.syncDelay", Long.toString(syncDelay)); try { InputStream in = getClass().getResourceAsStream( "/org/apache/jackrabbit/core/cluster/repository.xml"); RepositoryConfig config = RepositoryConfig.create(in, DIR.getPath()); ClusterConfig clusterConfig = config.getClusterConfig(); assertEquals(id, clusterConfig.getId()); assertEquals(syncDelay, clusterConfig.getSyncDelay()); } finally { System.clearProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID); System.clearProperty("cluster.syncDelay"); } }
setDescriptor(JACKRABBIT_CLUSTER_ID, repConfig.getClusterConfig().getId()); try { clusterNode.start();
assertEquals(id, clusterConfig.getId()); assertEquals(syncDelay, clusterConfig.getSyncDelay()); assertEquals(id, clusterConfig.getId()); assertEquals(syncDelay, clusterConfig.getSyncDelay()); } finally { System.clearProperty("cluster.syncDelay");
setDescriptor(JACKRABBIT_CLUSTER_ID, repConfig.getClusterConfig().getId()); try { clusterNode.start();
/** * Initialize this cluster node (overridable). * * @throws ClusterException if an error occurs */ protected void init() throws ClusterException { ClusterConfig cc = clusterContext.getClusterConfig(); clusterNodeId = cc.getId(); syncDelay = cc.getSyncDelay(); stopDelay = cc.getStopDelay(); try { journal = cc.getJournal(clusterContext.getNamespaceResolver()); instanceRevision = journal.getInstanceRevision(); journal.register(this); producer = journal.getProducer(PRODUCER_ID); } catch (RepositoryException e) { throw new ClusterException( "Cluster initialization failed: " + this, e); } catch (JournalException e) { throw new ClusterException( "Journal initialization failed: " + this, e); } }
return new ClusterConfig(id, syncDelay, stopDelay, jf);
/** * Verify that <code>ClusterNode.stop</code> can be invoked even when * <code>ClusterNode.init</code> throws because of a bad journal class. * * @throws Exception */ public void testClusterInitIncompleteBadJournalClass() throws Exception { JournalFactory jf = new JournalFactory() { public Journal getJournal(NamespaceResolver resolver) throws RepositoryException { throw new RepositoryException("Journal not available"); } }; ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf); SimpleClusterContext context = new SimpleClusterContext(cc); ClusterNode clusterNode = new ClusterNode(); try { clusterNode.init(context); fail("Bad cluster configuration."); } catch (Exception e) { } clusterNode.stop(); }
/** * Create a journal with no revision file name. Verify that the journal * is created nonetheless, with a revision file in the repository home. * * @throws Exception * @see <a href="http://issues.apache.org/jira/browse/JCR-904">JCR-904</a> */ public void testRevisionIsOptional() throws Exception { final FileJournal journal = new FileJournal(); journal.setDirectory(journalDirectory.getPath()); JournalFactory jf = new JournalFactory() { public Journal getJournal(NamespaceResolver resolver) { return journal; } }; ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf); SimpleClusterContext context = new SimpleClusterContext(cc, repositoryHome); journal.setRepositoryHome(repositoryHome); journal.init(CLUSTER_NODE_ID, context.getNamespaceResolver()); ClusterNode clusterNode = new ClusterNode(); clusterNode.init(context); try { File revisionFile = new File(repositoryHome, FileJournal.DEFAULT_INSTANCE_FILE_NAME); assertTrue(revisionFile.exists()); } finally { clusterNode.stop(); } }
ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf); SimpleClusterContext context = new SimpleClusterContext(cc);
private ClusterNode createClusterNode(String id) throws Exception { final MemoryJournal journal = new MemoryJournal() { protected boolean syncAgainOnNewRecords() { return true; } }; JournalFactory jf = new JournalFactory() { public Journal getJournal(NamespaceResolver resolver) throws RepositoryException { return journal; } }; ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jf); SimpleClusterContext context = new SimpleClusterContext(cc); journal.setRepositoryHome(context.getRepositoryHome()); journal.init(id, context.getNamespaceResolver()); journal.setRecords(records); ClusterNode clusterNode = new ClusterNode(); clusterNode.init(context); return clusterNode; }
/** * Create a cluster node, with a memory journal referencing a list of records. * * @param id cluster node id * @param records memory journal's list of records */ private ClusterNode createClusterNode( String id, ArrayList<MemoryRecord> records) throws Exception { final MemoryJournal journal = new MemoryJournal(); JournalFactory jf = new JournalFactory() { public Journal getJournal(NamespaceResolver resolver) throws RepositoryException { return journal; } }; ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jf); SimpleClusterContext context = new SimpleClusterContext(cc); journal.setRepositoryHome(context.getRepositoryHome()); journal.init(id, context.getNamespaceResolver()); if (records != null) { journal.setRecords(records); } ClusterNode clusterNode = new ClusterNode(); clusterNode.init(context); return clusterNode; } }
ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jf); SimpleClusterContext context = new SimpleClusterContext(cc);