Ejemplo n.º 1
0
 public BatchConsumer(IConsumerBarrier <T> consumerBarrier,
                      IBatchHandler <T> handler)
 {
     _consumerBarrier   = consumerBarrier;
     _handler           = handler;
     _noSequenceTracker = true;
 }
Ejemplo n.º 2
0
        public void Add(IBatchConsumer batchConsumer, IBatchHandler <T> handler)
        {
            var consumerInfo = new ConsumerInfo <T>(batchConsumer, handler);

            _consumerInfoByHandler[handler]        = consumerInfo;
            _consumerInfoByConsumer[batchConsumer] = consumerInfo;
        }
Ejemplo n.º 3
0
        public BatchConsumer(IConsumerBarrier <T> consumerBarrier,
                             ISequenceTrackingHandler <T> entryHandler)
        {
            _consumerBarrier = consumerBarrier;
            _handler         = entryHandler;

            _noSequenceTracker = false;
            entryHandler.SetSequenceTrackerCallback(new SequenceTrackerCallback(this));
        }
Ejemplo n.º 4
0
 public SharpBatchMiddleware(
     RequestDelegate next,
     ILogger <SharpBatchMiddleware> logger,
     IBatchHandler batchHandler
     )
 {
     _next         = next;
     _logger       = logger;
     _batchHandler = batchHandler;
 }
		public void SetUp()
		{
			_mocks = new MockRepository();
			_latch = new AutoResetEvent(false);
			
			ringBuffer = new RingBuffer<StubEntry>(new StubFactory(), 16);
			consumerBarrier = ringBuffer.CreateConsumerBarrier();
			batchHandler = _mocks.DynamicMock<IBatchHandler<StubEntry>>();
			batchConsumer = new BatchConsumer<StubEntry>(consumerBarrier, batchHandler);
			producerBarrier = ringBuffer.CreateProducerBarrier(batchConsumer);
		}
Ejemplo n.º 6
0
        public void SetUp()
        {
            _mocks = new MockRepository();
            _latch = new AutoResetEvent(false);

            ringBuffer      = new RingBuffer <StubEntry>(new StubFactory(), 16);
            consumerBarrier = ringBuffer.CreateConsumerBarrier();
            batchHandler    = _mocks.DynamicMock <IBatchHandler <StubEntry> >();
            batchConsumer   = new BatchConsumer <StubEntry>(consumerBarrier, batchHandler);
            producerBarrier = ringBuffer.CreateProducerBarrier(batchConsumer);
        }
        /// <summary>
        /// Creates a new instance of the <see cref="SqlSyncProviderService" /> class. Also uses the batch handler passed as parameter if it is not null.
        /// </summary>
        /// <param name="configuration">Sync configuration</param>
        /// <param name="serverScope">Server scope/template</param>
        /// <param name="filterParams">Filter parameters. Pass null for no filter parameters.</param>
        /// <param name="operationContext">SyncOperationContext object to create the SyncConflictContext object.</param>
        /// <param name="batchHandler">Batch Handler for spooling and retrieving batches.</param>
        internal SqlSyncProviderService(SyncServiceConfiguration configuration, string serverScope, List<SqlSyncProviderFilterParameterInfo> filterParams,
                                        SyncOperationContext operationContext, IBatchHandler batchHandler)
        {
            WebUtil.CheckArgumentNull(serverScope, "serverScope");

            _configuration = configuration;
            _serverConnectionString = _configuration.ServerConnectionString;
            _scopeName = serverScope;
            _conflictResolutionPolicy = _configuration.ConflictResolutionPolicy;

            _filterParams = filterParams;

            _converter = new DataSetToEntitiesConverter(_configuration.TableGlobalNameToTypeMapping,
                                                        _configuration.TypeToTableGlobalNameMapping,
                                                        _configuration.TypeToTableLocalNameMapping);

            _batchHandler = batchHandler ?? new FileBasedBatchHandler(_configuration.BatchSpoolDirectory);
            
            if (operationContext != null)
            {
                _conflictContext = new SyncConflictContext()
                {
                    ScopeName = serverScope,
                    Operation = SyncOperations.Upload,
                    RequestHeaders = operationContext.RequestHeaders,
                    ResponseHeaders = operationContext.ResponseHeaders,
                    QueryString = operationContext.QueryString
                };
            }
        }
Ejemplo n.º 8
0
 public IBatchConsumer GetConsumerFor(IBatchHandler <T> handler)
 {
     return(_consumerInfoByHandler[handler].BatchConsumer);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initialize a new <see cref="BatchUtils"/>
 /// </summary>
 /// <param name="batchHandler"></param>
 public BatchUtils(IBatchHandler batchHandler)
 {
     _batchHandler = batchHandler;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Construct a batch consumer that will automatically track the progress by updating its sequence when
 /// the <see cref="IBatchHandler{T}.OnAvailable"/> method returns.
 /// </summary>
 /// <param name="consumerBarrier">consumerBarrier on which it is waiting.</param>
 /// <param name="handler">handler is the delegate to which <see cref="Entry{T}"/>s are dispatched.</param>
 public BatchConsumer(IConsumerBarrier <T> consumerBarrier, IBatchHandler <T> handler)
 {
     _consumerBarrier = consumerBarrier;
     _handler         = handler;
 }
Ejemplo n.º 11
0
 public ConsumerInfo(IBatchConsumer batchConsumer, IBatchHandler <T> handler)
 {
     BatchConsumer = batchConsumer;
     Handler       = handler;
     IsEndOfChain  = true;
 }