Skip to content

Exposed the existing "disableAutoSync" property of ClusterNode to external configuration. #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ protected void init() throws ClusterException {
clusterNodeId = cc.getId();
syncDelay = cc.getSyncDelay();
stopDelay = cc.getStopDelay();
disableAutoSync = cc.isDisableAutoSync();

try {
journal = cc.getJournal(clusterContext.getNamespaceResolver());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public class ClusterConfig implements JournalFactory {
*/
private final JournalFactory jf;

/**
* Disable auto sync
*/
private final boolean disableAutoSync;

/**
* Creates a new cluster configuration.
*
Expand All @@ -68,10 +73,26 @@ public ClusterConfig(String id, long syncDelay, JournalFactory jf) {
*/
public ClusterConfig(String id, long syncDelay,
long stopDelay, JournalFactory jf) {
this (id, syncDelay, stopDelay, jf, false);
}

/**
* Creates a new cluster configuration.
*
* @param id custom cluster node id
* @param syncDelay syncDelay, in milliseconds
* @param stopDelay stopDelay in milliseconds
* @param jf journal factory
* @param disableAutoSync trye if auto sync is disabled
*/
public ClusterConfig(String id, long syncDelay,
long stopDelay, JournalFactory jf,
boolean disableAutoSync) {
this.id = id;
this.syncDelay = syncDelay;
this.stopDelay = stopDelay < 0 ? syncDelay * 10 : stopDelay;
this.jf = jf;
this.disableAutoSync = disableAutoSync;
}

/**
Expand Down Expand Up @@ -112,4 +133,10 @@ public Journal getJournal(NamespaceResolver resolver)
return jf.getJournal(resolver);
}

/**
* @return disableAutoSync true if auto sync is disabled
*/
public boolean isDisableAutoSync() {
return disableAutoSync;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ public class RepositoryConfigurationParser extends ConfigurationParser {
/** Name of the stopDelay configuration attribute. */
public static final String STOP_DELAY_ATTRIBUTE = "stopDelay";

/** Name of the disableAutoSync configuration attribute. */
public static final String DISABLE_AUTO_SYNC_ATTRIBUTE = "disableAutoSync";

/** Name of the default search index implementation class. */
public static final String DEFAULT_QUERY_HANDLER =
"org.apache.jackrabbit.core.query.lucene.SearchIndex";
Expand Down Expand Up @@ -895,7 +898,11 @@ protected ClusterConfig parseClusterConfig(Element parent, File home)
element, STOP_DELAY_ATTRIBUTE, "-1")));

JournalFactory jf = getJournalFactory(element, home, id);
return new ClusterConfig(id, syncDelay, stopDelay, jf);

boolean disableAutoSync = Boolean.parseBoolean(replaceVariables(getAttribute(
element, DISABLE_AUTO_SYNC_ATTRIBUTE, "false")));

return new ClusterConfig(id, syncDelay, stopDelay, jf, disableAutoSync);
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,33 @@ public void run() {
assertEquals(master.getRevision(), slave.getRevision());
}

/**
* Verify that a cluster node with sync disabled does not fetch results when changes
* are made.
*
* @throws Exception
*/
public void testSyncDisabled() throws Exception {
// create channel on master and slave
LockEventChannel channel = master.createLockChannel(DEFAULT_WORKSPACE);
channel.setListener(new SimpleEventListener());

// add first entry
LockEvent event = new LockEvent(NodeId.randomId(), true, "admin");
channel.create(event.getNodeId(), event.isDeep(), event.getUserId()).ended(true);

// do not sync slave

// add second entry
event = new LockEvent(NodeId.randomId(), true, "admin");
channel.create(event.getNodeId(), event.isDeep(), event.getUserId()).ended(true);

long masterRevision = master.getRevision();
long slaveRevision = slave.getRevision();

assertTrue(masterRevision > slaveRevision);
}

/**
* Create a cluster node, with a memory journal referencing a list of records.
*
Expand Down