Class RouterService
java.lang.Object
org.jumpmind.symmetric.service.impl.AbstractService
org.jumpmind.symmetric.service.impl.RouterService
- All Implemented Interfaces:
INodeCommunicationService.INodeCommunicationExecutor,IRouterService,IService
public class RouterService
extends AbstractService
implements IRouterService, INodeCommunicationService.INodeCommunicationExecutor
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected longprotected ISymmetricEngineprotected IExtensionServiceprotected booleanprotected DataGapDetectorprotected Map<String,CounterStat> protected booleanprotected Map<Integer,CounterStat> protected Map<Integer,CounterStat> protected ExecutorServiceprotected longprotected booleanFields inherited from class org.jumpmind.symmetric.service.impl.AbstractService
log, parameterService, platform, sqlTemplate, sqlTemplateDirty, symmetricDialect, tablePrefix -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TablebuildTableFromTriggerHistory(TriggerHistory triggerHistory) protected voidcompleteBatches(ChannelRouterContext context, List<OutgoingBatch> batches, Set<IDataRouter> usedRouters) protected voidprotected booleandoesColumnCountMatchValues(DataMetaData dataMetaData, Data data) voidexecute(NodeCommunication nodeCommunication, RemoteNodeStatus status) findAvailableNodes(TriggerRouter triggerRouter, ChannelRouterContext context) voidGet a list of available batch algorithms that can be used for the different channelsprotected IDataRoutergetDataRouter(Router router, DataMetaData dataMetaData) protected List<TriggerRouter>getTriggerRoutersForData(Data data, ChannelRouterContext context) longprotected booleanprotected intinsertDataEvents(ProcessInfo processInfo, ChannelRouterContext context, DataMetaData dataMetaData, Collection<String> nodeIds, TriggerRouter triggerRouter) protected booleanprotected booleanonlyDefaultRoutersAssigned(Channel channel, String nodeGroupId, List<TriggerRouter> triggerRouters) protected booleanproducesCommonBatches(Channel channel, String nodeGroupId, List<TriggerRouter> triggerRouters) Deprecated.protected StringqualifyUsingDataGaps(List<DataGap> dataGaps, int numberOfGapsToQualify, String sql) longrouteData(boolean force) This method will route data to specific nodes.protected introuteData(ProcessInfo processInfo, Data data, ChannelRouterContext context) protected longrouteDataForChannel(ProcessInfo processInfo, NodeChannel nodeChannel, Node sourceNode, NodeCommunication nodeCommunication, ChannelRouterContext context) protected longWe route data channel by channel for two reasons.protected longselectDataAndRoute(ProcessInfo processInfo, NodeCommunication nodeCommunication, ChannelRouterContext context) Pre-read data and fill up a queue so we can peek ahead to see if we have crossed a database transaction boundary.booleanshouldDataBeRouted(SimpleRouterContext context, DataMetaData dataMetaData, Node node, boolean initialLoad, boolean initialLoadSelectUsed, TriggerRouter triggerRouter) For use in data load eventsprotected IDataToRouteReaderstartReading(ChannelRouterContext context) voidstop()Methods inherited from class org.jumpmind.symmetric.service.impl.AbstractService
assertNotNull, buildBatchOrderBy, buildBatchParams, buildBatchWhere, buildBatchWhereFromFilter, close, createSqlReplacementTokens, getJdbcTemplate, getParameterService, getSql, getSymmetricDialect, getTablePrefix, getTargetDialect, getTargetPlatform, getTargetPlatform, isCalledFromSymmetricAdminTool, isSet, isStreamClosedByClient, isSymmetricTable, logOnce, maxDate, readAcks, sendAck, setSqlMap, synchronize, toNodeIds, toNodeIdsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jumpmind.symmetric.service.IService
getSql, synchronize
-
Field Details
-
missingTriggerRouter
-
invalidRouterType
-
missingColumns
-
triggerRouterCacheTime
protected long triggerRouterCacheTime -
commonBatchesLastKnownState
-
commonBatchesCacheTime
protected long commonBatchesCacheTime -
defaultRouterOnlyLastKnownState
-
defaultRoutersCacheTime
protected long defaultRoutersCacheTime -
isAllDataReadByChannel
-
hasMaxDataRoutedByChannel
-
readThread
-
engine
-
extensionService
-
gapDetector
-
firstTimeCheck
protected boolean firstTimeCheck -
isUsingTargetExternalId
protected boolean isUsingTargetExternalId -
useChannelThreading
protected boolean useChannelThreading
-
-
Constructor Details
-
RouterService
-
-
Method Details
-
shouldDataBeRouted
public boolean shouldDataBeRouted(SimpleRouterContext context, DataMetaData dataMetaData, Node node, boolean initialLoad, boolean initialLoadSelectUsed, TriggerRouter triggerRouter) For use in data load events- Specified by:
shouldDataBeRoutedin interfaceIRouterService
-
stop
public void stop()- Specified by:
stopin interfaceIRouterService
-
flushCache
public void flushCache()- Specified by:
flushCachein interfaceIRouterService
-
routeData
public long routeData(boolean force) This method will route data to specific nodes.- Specified by:
routeDatain interfaceIRouterService
-
routeDataForEachChannel
protected long routeDataForEachChannel()We route data channel by channel for two reasons. One is that if/when we decide to multi-thread the routing it is a simple matter of inserting a thread pool here and waiting for all channels to be processed. The other reason is to reduce the number of connections we are required to have. -
getReadyChannels
-
qualifyUsingDataGaps
-
producesCommonBatches
@Deprecated protected boolean producesCommonBatches(Channel channel, String nodeGroupId, List<TriggerRouter> triggerRouters) Deprecated. -
onlyDefaultRoutersAssigned
protected boolean onlyDefaultRoutersAssigned(Channel channel, String nodeGroupId, List<TriggerRouter> triggerRouters) -
execute
- Specified by:
executein interfaceINodeCommunicationService.INodeCommunicationExecutor
-
routeDataForChannel
protected long routeDataForChannel(ProcessInfo processInfo, NodeChannel nodeChannel, Node sourceNode, NodeCommunication nodeCommunication, ChannelRouterContext context) -
completeBatchesAndCommit
-
completeBatches
protected void completeBatches(ChannelRouterContext context, List<OutgoingBatch> batches, Set<IDataRouter> usedRouters) -
findAvailableNodes
-
startReading
-
selectDataAndRoute
protected long selectDataAndRoute(ProcessInfo processInfo, NodeCommunication nodeCommunication, ChannelRouterContext context) throws InterruptedException Pre-read data and fill up a queue so we can peek ahead to see if we have crossed a database transaction boundary. Then route eachDatawhile continuing to keep the queue filled until the result set is entirely read.- Parameters:
conn- The connection to use for selecting the data.context- The current context of the routing process- Throws:
InterruptedException
-
routeData
-
insertDataEvents
protected int insertDataEvents(ProcessInfo processInfo, ChannelRouterContext context, DataMetaData dataMetaData, Collection<String> nodeIds, TriggerRouter triggerRouter) -
getDataRouter
-
getTriggerRoutersForData
-
getUnroutedDataCount
public long getUnroutedDataCount()- Specified by:
getUnroutedDataCountin interfaceIRouterService
-
getAvailableBatchAlgorithms
Description copied from interface:IRouterServiceGet a list of available batch algorithms that can be used for the different channels- Specified by:
getAvailableBatchAlgorithmsin interfaceIRouterService
-
getRouters
- Specified by:
getRoutersin interfaceIRouterService
-
getDataGaps
- Specified by:
getDataGapsin interfaceIRouterService
-
buildTableFromTriggerHistory
-
doesColumnCountMatchValues
-
hasMaxDataRouted
protected boolean hasMaxDataRouted() -
isAllDataRead
protected boolean isAllDataRead()
-