From 504aca3f46c508cb6cbae6ff024ff5e542701d3d Mon Sep 17 00:00:00 2001 From: chenson42 Date: Fri, 29 May 2009 16:39:27 +0000 Subject: [PATCH] Don't update the default channels every time a server restarts --- .../org/jumpmind/symmetric/model/Channel.java | 17 +++++++++++++++++ .../service/impl/BootstrapService.java | 9 +++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/model/Channel.java b/symmetric/src/main/java/org/jumpmind/symmetric/model/Channel.java index 1e4263197d..14d070e1f4 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/model/Channel.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/model/Channel.java @@ -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. @@ -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 channels) { + if (channels != null) { + for (Channel channel : channels) { + if (channel.getId().equals(id)) { + return true; + } + } + } + return false; + } } diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/BootstrapService.java b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/BootstrapService.java index 7a74115192..efca88fabf 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/BootstrapService.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/service/impl/BootstrapService.java @@ -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; @@ -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 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();