use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class FileSyncService method getBatchesToProcess.
protected List<OutgoingBatch> getBatchesToProcess(Node targetNode) {
List<OutgoingBatch> batchesToProcess = new ArrayList<OutgoingBatch>();
List<Channel> fileSyncChannels = engine.getConfigurationService().getFileSyncChannels();
OutgoingBatches batches = engine.getOutgoingBatchService().getOutgoingBatches(targetNode.getNodeId(), false);
for (Channel channel : fileSyncChannels) {
batchesToProcess.addAll(batches.filterBatchesForChannel(channel));
}
return batchesToProcess;
}
use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class OutgoingBatchService method getOutgoingBatches.
@Override
public OutgoingBatches getOutgoingBatches(String nodeId, String channelThread, NodeGroupLinkAction eventAction, NodeGroupLinkAction defaultEventAction, boolean includeDisabledChannels) {
long ts = System.currentTimeMillis();
final int maxNumberOfBatchesToSelect = parameterService.getInt(ParameterConstants.OUTGOING_BATCH_MAX_BATCHES_TO_SELECT, 1000);
String sql = null;
Object[] params = null;
int[] types = null;
if (eventAction != null) {
if (eventAction.equals(defaultEventAction)) {
sql = getSql("selectOutgoingBatchPrefixSql", "selectOutgoingBatchChannelActionNullSql");
} else {
sql = getSql("selectOutgoingBatchPrefixSql", "selectOutgoingBatchChannelActionSql");
}
params = new Object[] { eventAction.name(), nodeId, channelThread, OutgoingBatch.Status.RQ.name(), OutgoingBatch.Status.NE.name(), OutgoingBatch.Status.QY.name(), OutgoingBatch.Status.SE.name(), OutgoingBatch.Status.LD.name(), OutgoingBatch.Status.ER.name(), OutgoingBatch.Status.IG.name(), OutgoingBatch.Status.RS.name() };
types = new int[] { Types.CHAR, Types.VARCHAR, Types.VARCHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR };
} else if (channelThread != null) {
sql = getSql("selectOutgoingBatchPrefixSql", "selectOutgoingBatchChannelSql");
params = new Object[] { nodeId, channelThread, OutgoingBatch.Status.RQ.name(), OutgoingBatch.Status.NE.name(), OutgoingBatch.Status.QY.name(), OutgoingBatch.Status.SE.name(), OutgoingBatch.Status.LD.name(), OutgoingBatch.Status.ER.name(), OutgoingBatch.Status.IG.name(), OutgoingBatch.Status.RS.name() };
types = new int[] { Types.VARCHAR, Types.VARCHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR };
} else {
sql = getSql("selectOutgoingBatchPrefixSql", "selectOutgoingBatchSql");
params = new Object[] { nodeId, OutgoingBatch.Status.RQ.name(), OutgoingBatch.Status.NE.name(), OutgoingBatch.Status.QY.name(), OutgoingBatch.Status.SE.name(), OutgoingBatch.Status.LD.name(), OutgoingBatch.Status.ER.name(), OutgoingBatch.Status.IG.name(), OutgoingBatch.Status.RS.name() };
types = new int[] { Types.VARCHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR };
}
List<OutgoingBatch> list = (List<OutgoingBatch>) sqlTemplate.query(sql, maxNumberOfBatchesToSelect, new OutgoingBatchMapper(includeDisabledChannels), params, types);
OutgoingBatches batches = new OutgoingBatches(list);
List<NodeChannel> channels = new ArrayList<NodeChannel>(configurationService.getNodeChannels(nodeId, true));
batches.sortChannels(channels);
List<IOutgoingBatchFilter> filters = extensionService.getExtensionPointList(IOutgoingBatchFilter.class);
List<OutgoingBatch> keepers = new ArrayList<OutgoingBatch>();
for (NodeChannel channel : channels) {
List<OutgoingBatch> batchesForChannel = getBatchesForChannelWindows(batches, nodeId, channel, configurationService.getNodeGroupChannelWindows(parameterService.getNodeGroupId(), channel.getChannelId()));
if (filters != null) {
for (IOutgoingBatchFilter filter : filters) {
batchesForChannel = filter.filter(channel, batchesForChannel);
}
}
if (parameterService.is(ParameterConstants.DATA_EXTRACTOR_ENABLED) || channel.getChannelId().equals(Constants.CHANNEL_CONFIG)) {
keepers.addAll(batchesForChannel);
}
}
batches.setBatches(keepers);
long executeTimeInMs = System.currentTimeMillis() - ts;
if (executeTimeInMs > Constants.LONG_OPERATION_THRESHOLD) {
log.info("Selecting {} outgoing batch rows for node {} on queue '{}' took {} ms", list.size(), nodeId, channelThread, executeTimeInMs);
}
return batches;
}
use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class OutgoingBatchService method markAllConfigAsSentForNode.
public void markAllConfigAsSentForNode(String nodeId) {
int updateCount;
do {
updateCount = 0;
OutgoingBatches batches = getOutgoingBatches(nodeId, false);
List<OutgoingBatch> list = batches.getBatches();
for (OutgoingBatch outgoingBatch : list) {
if (outgoingBatch.getChannelId().equals(Constants.CHANNEL_CONFIG)) {
outgoingBatch.setStatus(Status.OK);
outgoingBatch.setErrorFlag(false);
outgoingBatch.setIgnoreCount(1);
updateOutgoingBatch(outgoingBatch);
updateCount++;
}
}
} while (updateCount > 0);
}
use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class OutgoingBatchService method getOutgoingBatchErrors.
public OutgoingBatches getOutgoingBatchErrors(int maxRows) {
OutgoingBatches batches = new OutgoingBatches();
batches.setBatches(sqlTemplate.query(getSql("selectOutgoingBatchPrefixSql", "selectOutgoingBatchErrorsSql"), maxRows, new OutgoingBatchMapper(true), null, null));
return batches;
}
use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method testSyncIncomingBatchWhenUnrouted.
public void testSyncIncomingBatchWhenUnrouted() throws Exception {
resetBatches();
TriggerRouter triggerRouter = getTestRoutingTableTrigger(TEST_TABLE_1);
triggerRouter.getTrigger().setSyncOnIncomingBatch(true);
triggerRouter.getRouter().setRouterType("bsh");
triggerRouter.getRouter().setRouterExpression("return " + NODE_GROUP_NODE_1.getNodeId());
getTriggerRouterService().saveTriggerRouter(triggerRouter);
NodeChannel testChannel = getConfigurationService().getNodeChannel(TestConstants.TEST_CHANNEL_ID, false);
testChannel.setMaxBatchToSend(1000);
testChannel.setMaxBatchSize(50);
testChannel.setBatchAlgorithm("default");
getConfigurationService().saveChannel(testChannel, true);
getTriggerRouterService().syncTriggers();
insert(TEST_TABLE_1, 10, true, NODE_GROUP_NODE_1.getNodeId());
int unroutedCount = countUnroutedBatches();
getRouterService().routeData(true);
OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false);
filterForChannels(batches, testChannel);
Assert.assertEquals("Should have been 0. We did the insert as if the data had come from node 1.", 0, batches.getBatches().size());
Assert.assertTrue(countUnroutedBatches() > unroutedCount);
resetBatches();
}
Aggregations