org.jumpmind.symmetric.route.TriggerDataRouter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of symmetric-ds Show documentation
Show all versions of symmetric-ds Show documentation
SymmetricDS is an open source database synchronization solution. It is platform-independent,
web-enabled, and database-agnostic. SymmetricDS was first built to replicate changes between 'retail store'
databases and ad centralized 'corporate' database.
The newest version!
/*
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU Lesser General Public License (the
* "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* .
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.route;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.jumpmind.symmetric.Version;
import org.jumpmind.symmetric.model.DataMetaData;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.OutgoingBatch;
/**
* This is a router that is tied to the trigger table. It prevents triggers from
* being routed to pre-2.0 versions of SymmetricDS.
*/
public class TriggerDataRouter extends AbstractDataRouter {
public void completeBatch(IRouterContext context, OutgoingBatch batch) {
}
public Collection routeToNodes(IRouterContext context, DataMetaData dataMetaData,
Set nodes, boolean initialLoad) {
Set nodeIds = new HashSet();
if (!initialLoad) {
for (Node node : nodes) {
String version = node.getSymmetricVersion();
if (version != null) {
int max = Version.parseVersion(version)[Version.MAJOR_INDEX];
if (max >= 2) {
nodeIds.add(node.getNodeId());
}
}
}
return nodeIds;
} else {
return toNodeIds(nodes, nodeIds);
}
}
public boolean isAutoRegister() {
return false;
}
}