Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't update the default channels every time a server restarts
  • Loading branch information
chenson42 committed May 29, 2009
1 parent a6a4d99 commit 504aca3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
17 changes: 17 additions & 0 deletions symmetric/src/main/java/org/jumpmind/symmetric/model/Channel.java
Expand Up @@ -20,6 +20,8 @@

package org.jumpmind.symmetric.model;

import java.util.Collection;

/**
* Definition of a channel and it's priority. A channel is a group of tables
* that get synchronized together.
Expand Down Expand Up @@ -94,4 +96,19 @@ public int getMaxBatchToSend() {
public void setMaxBatchToSend(int maxBatchToSend) {
this.maxBatchToSend = maxBatchToSend;
}

/**
* Check to see if this channel id matches one of the channels in the collection
* @return true if a match is found
*/
public boolean isInList(Collection<? extends Channel> channels) {
if (channels != null) {
for (Channel channel : channels) {
if (channel.getId().equals(id)) {
return true;
}
}
}
return false;
}
}
Expand Up @@ -48,6 +48,7 @@
import org.jumpmind.symmetric.model.Channel;
import org.jumpmind.symmetric.model.DataEventType;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.NodeChannel;
import org.jumpmind.symmetric.model.Trigger;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.jumpmind.symmetric.model.TriggerReBuildReason;
Expand Down Expand Up @@ -105,9 +106,13 @@ private void autoConfigDatabase(boolean force) {
logger.info("Initializing SymmetricDS database.");
dbDialect.initSupportDb();
if (defaultChannels != null) {
logger.info("Setting up " + defaultChannels.size() + " default channels");
configurationService.flushChannels();
List<NodeChannel> channels = configurationService.getChannels();
for (Channel defaultChannel : defaultChannels) {
configurationService.saveChannel(defaultChannel);
if (!defaultChannel.isInList(channels)) {
logger.info(String.format("Auto configuring %s channel", defaultChannel.getId()));
configurationService.saveChannel(defaultChannel);
}
}
}
parameterService.rereadParameters();
Expand Down

0 comments on commit 504aca3

Please sign in to comment.