public DistributorModule( AsyncTasksConfiguration asyncPing, AsyncTasksConfiguration asyncCheck, DistributorHashConfiguration configuration, QueueConfiguration queueConfiguration, DistributorNetModule distributorNet, ServerId localfordb, ServerId localforproxy, HashMapConfiguration hashMapConfiguration) { Contract.Requires(configuration != null); Contract.Requires(queueConfiguration != null); Contract.Requires(distributorNet != null); Contract.Requires(localfordb != null); Contract.Requires(localforproxy != null); Contract.Requires(asyncPing != null); _asyncPing = asyncPing; _asyncTaskModule = new AsyncTaskModule(queueConfiguration); _queueConfiguration = queueConfiguration; _modelOfDbWriters = new WriterSystemModel(configuration, hashMapConfiguration); _modelOfAnotherDistributors = new DistributorSystemModel(); _distributorNet = distributorNet; _localfordb = localfordb; _localforproxy = localforproxy; _asyncCheck = asyncCheck; _queue = GlobalQueue.Queue; }
public DistributorModule(CollectorModel model, AsyncTaskModule asyncTaskModule, AsyncTasksConfiguration asyncPing) { _model = model; _asyncTaskModule = asyncTaskModule; _asyncPing = asyncPing; }
protected ProxyApi(NetConfiguration netConfiguration, ProxyConfiguration proxyConfiguration, CommonConfiguration commonConfiguration, TimeoutConfiguration timeoutConfiguration) { Contract.Requires(netConfiguration != null); Contract.Requires(proxyConfiguration != null); Contract.Requires(commonConfiguration != null); Contract.Requires(timeoutConfiguration != null); _isStarted = false; _isBuild = false; _isDispose = false; var server = new ServerId(netConfiguration.Host, netConfiguration.Port); var queue = new QueueConfiguration(commonConfiguration.CountThreads, commonConfiguration.QueueSize); var connection = new ConnectionConfiguration(netConfiguration.WcfServiceName, netConfiguration.CountConnectionsToSingleServer); var proxyCacheConfiguration = new ProxyCacheConfiguration(proxyConfiguration.ChangeDistributorTimeoutSec); var proxyCacheConfiguration2 = new ProxyCacheConfiguration(proxyConfiguration.SyncOperationsTimeoutSec); var netReceiveConfiguration = new NetReceiverConfiguration(netConfiguration.Port, netConfiguration.Host, netConfiguration.WcfServiceName); var async = new AsyncTasksConfiguration(proxyConfiguration.AsyncUpdateTimeout); var ping = new AsyncTasksConfiguration(proxyConfiguration.AsyncPingTimeout); var timeout = new ConnectionTimeoutConfiguration(timeoutConfiguration.OpenTimeout, timeoutConfiguration.SendTimeout); _proxySystem = new ProxySystem(server, queue, connection, proxyCacheConfiguration, proxyCacheConfiguration2, netReceiveConfiguration, async, ping, timeout); _apis = new Dictionary <string, ProxyHandlerBase>(); }
public ProxySystem(ServerId local, QueueConfiguration queueConfiguration, ConnectionConfiguration connectionConfiguration, ProxyCacheConfiguration cacheConfiguration, ProxyCacheConfiguration asyncCacheConfiguration, NetReceiverConfiguration receiverConfiguration, AsyncTasksConfiguration asyncGetData, AsyncTasksConfiguration asyncPing, ConnectionTimeoutConfiguration connectionTimeoutConfiguration) { Contract.Requires(queueConfiguration != null); Contract.Requires(connectionConfiguration != null); Contract.Requires(cacheConfiguration != null); Contract.Requires(asyncCacheConfiguration != null); Contract.Requires(receiverConfiguration != null); Contract.Requires(asyncGetData != null); Contract.Requires(local != null); Contract.Requires(asyncPing != null); _local = local; _queueConfiguration = queueConfiguration; _connectionConfiguration = connectionConfiguration; _cacheConfiguration = cacheConfiguration; _asyncCacheConfiguration = asyncCacheConfiguration; _netReceiverConfiguration = receiverConfiguration; _asyncGetData = asyncGetData; _asyncPing = asyncPing; _connectionTimeoutConfiguration = connectionTimeoutConfiguration; }
public DistributorModule(AsyncTaskModule async, AsyncDbWorkModule asyncDbWork, WriterNetModule writerNet, ServerId local, HashMapConfiguration hashMapConfiguration, QueueConfiguration configuration, DbModuleCollection dbModuleCollection, AsyncTasksConfiguration pingConfiguration = null) { Contract.Requires(local != null); Contract.Requires(writerNet != null); Contract.Requires(configuration != null); Contract.Requires(asyncDbWork != null); Contract.Requires(async != null); Contract.Assert(dbModuleCollection != null); _async = async; _asyncDbWork = asyncDbWork; _model = new WriterModel(local, hashMapConfiguration); _writerNet = writerNet; _queueConfiguration = configuration; _dbModuleCollection = dbModuleCollection; _queue = GlobalQueue.Queue; var ping = TimeSpan.FromMinutes(1); if (pingConfiguration != null) { ping = pingConfiguration.TimeoutPeriod; } _async.AddAsyncTask( new AsyncDataPeriod(ping, Ping, AsyncTasksNames.AsyncPing, -1), false); }
public TestProxySystem(ServerId local, QueueConfiguration queueConfiguration, ConnectionConfiguration connectionConfiguration, ProxyCacheConfiguration cacheConfiguration, ProxyCacheConfiguration asyncCacheConfiguration, NetReceiverConfiguration receiverConfiguration, AsyncTasksConfiguration asyncGetData, AsyncTasksConfiguration asyncPing, ConnectionTimeoutConfiguration connectionTimeoutConfiguration) : base( local, queueConfiguration, connectionConfiguration, cacheConfiguration, asyncCacheConfiguration, receiverConfiguration, asyncGetData, asyncPing, connectionTimeoutConfiguration) { }
public ProxyDistributorModule(AsyncProxyCache asyncProxyCache, ProxyNetModule net, QueueConfiguration queueConfiguration, ServerId local, AsyncTasksConfiguration asyncGetData, AsyncTasksConfiguration asyncPing) { _asyncProxyCache = asyncProxyCache; _asynPing = asyncPing; _queueConfiguration = queueConfiguration; _distributorSystemModel = new DistributorSystemModel(); _asynGetData = asyncGetData; _net = net; _local = local; _async = new AsyncTaskModule(queueConfiguration); _queue = GlobalQueue.Queue; }
public DistributorSystem(ServerId localfordb, ServerId localforproxy, DistributorHashConfiguration distributorHashConfiguration, QueueConfiguration queueConfiguration, ConnectionConfiguration connectionConfiguration, DistributorCacheConfiguration cacheConfiguration, NetReceiverConfiguration receiverConfigurationForDb, NetReceiverConfiguration receiverConfigurationForProxy, TransactionConfiguration transactionConfiguration, HashMapConfiguration hashMapConfiguration, AsyncTasksConfiguration pingConfig, AsyncTasksConfiguration checkConfig, ConnectionTimeoutConfiguration connectionTimeoutConfiguration) { Contract.Requires(distributorHashConfiguration != null); Contract.Requires(_queueConfiguration != null); Contract.Requires(connectionConfiguration != null); Contract.Requires(cacheConfiguration != null); Contract.Requires(receiverConfigurationForDb != null); Contract.Requires(receiverConfigurationForProxy != null); Contract.Requires(transactionConfiguration != null); Contract.Requires(localfordb != null); Contract.Requires(localforproxy != null); Contract.Requires(hashMapConfiguration != null); Contract.Requires(pingConfig != null); Contract.Requires(checkConfig != null); _pingConfig = pingConfig; _checkConfig = checkConfig; _connectionTimeoutConfiguration = connectionTimeoutConfiguration; _distributorHashConfiguration = distributorHashConfiguration; _hashMapConfiguration = hashMapConfiguration; _queueConfiguration = queueConfiguration; _connectionConfiguration = connectionConfiguration; _cacheConfiguration = cacheConfiguration; _receiverConfigurationForDb = receiverConfigurationForDb; _receiverConfigurationForProxy = receiverConfigurationForProxy; _transactionConfiguration = transactionConfiguration; _localfordb = localfordb; _localforproxy = localforproxy; }
public DistributorApi(DistributorNetConfiguration netConfiguration, DistributorConfiguration distributorConfiguration, CommonConfiguration commonConfiguration, TimeoutConfiguration timeoutConfiguration) { Contract.Requires(netConfiguration != null); Contract.Requires(distributorConfiguration != null); Contract.Requires(commonConfiguration != null); Contract.Requires(timeoutConfiguration != null); var dbServer = new ServerId(netConfiguration.Host, netConfiguration.PortForStorage); var proxyServer = new ServerId(netConfiguration.Host, netConfiguration.PortForProxy); var distrHash = new DistributorHashConfiguration(distributorConfiguration.CountReplics); var queue = new QueueConfiguration(commonConfiguration.CountThreads, commonConfiguration.QueueSize); var connection = new ConnectionConfiguration(netConfiguration.WcfServiceName, netConfiguration.CountConnectionsToSingleServer); var distrCache = new DistributorCacheConfiguration(distributorConfiguration.DataAliveTime, distributorConfiguration.DataAliveAfterUpdate); var dbNetReceive = new NetReceiverConfiguration(netConfiguration.PortForStorage, netConfiguration.Host, netConfiguration.WcfServiceName); var proxyNetReceive = new NetReceiverConfiguration(netConfiguration.PortForProxy, netConfiguration.Host, netConfiguration.WcfServiceName); var transaction = new TransactionConfiguration(commonConfiguration.CountThreads); var hashMap = new HashMapConfiguration(distributorConfiguration.FileWithHashName, HashMapCreationMode.ReadFromFile, 1, distributorConfiguration.CountReplics, HashFileType.Distributor); var asyncPing = new AsyncTasksConfiguration(distributorConfiguration.PingPeriod); var asyncCheck = new AsyncTasksConfiguration(distributorConfiguration.CheckPeriod); var timeou = new ConnectionTimeoutConfiguration(timeoutConfiguration.OpenTimeout, timeoutConfiguration.SendTimeout); _distributorSystem = new DistributorSystem(dbServer, proxyServer, distrHash, queue, connection, distrCache, dbNetReceive, proxyNetReceive, transaction, hashMap, asyncPing, asyncCheck, timeou); _handler = new DistributorHandler(_distributorSystem); }
public void ClientProxy_CrudOperations() { const int distrServer1 = 22206; const int distrServer12 = 22207; const int storageServer = 22208; #region hell var writer = new HashWriter(new HashMapConfiguration("TestClientProxy", HashMapCreationMode.CreateNew, 1, 1, HashFileType.Distributor)); writer.CreateMap(); writer.SetServer(0, "localhost", storageServer, 157); writer.Save(); var distrHash = new DistributorHashConfiguration(1); var queue = new QueueConfiguration(1, 100); var connection = new ConnectionConfiguration("testService", 10); var distrCache = new DistributorCacheConfiguration(TimeSpan.FromMilliseconds(10000), TimeSpan.FromMilliseconds(1000000)); var netReceive1 = new NetReceiverConfiguration(distrServer1, "localhost", "testService"); var netReceive12 = new NetReceiverConfiguration(distrServer12, "localhost", "testService"); var trans = new TransactionConfiguration(1); var hashMap = new HashMapConfiguration("TestClientProxy", HashMapCreationMode.ReadFromFile, 1, 1, HashFileType.Writer); var async = new AsyncTasksConfiguration(TimeSpan.FromSeconds(10)); var distr = new DistributorSystem(new ServerId("localhost", distrServer1), new ServerId("localhost", distrServer12), distrHash, queue, connection, distrCache, netReceive1, netReceive12, trans, new HashMapConfiguration("TestClientProxy", HashMapCreationMode.ReadFromFile, 1, 1, HashFileType.Distributor), async, async, new ConnectionTimeoutConfiguration(Consts.OpenTimeout, Consts.SendTimeout)); var netReceivedb = new NetReceiverConfiguration(storageServer, "localhost", "testService"); var restore = new RestoreModuleConfiguration(4, TimeSpan.FromMinutes(1)); var storage = new WriterSystem(new ServerId("localhost", storageServer), queue, netReceivedb, new NetReceiverConfiguration(1, "fake", "fake"), hashMap, connection, restore, restore, new ConnectionTimeoutConfiguration(Consts.OpenTimeout, Consts.SendTimeout), new RestoreModuleConfiguration(-1, TimeSpan.FromHours(1), false, TimeSpan.FromHours(1))); #endregion distr.Build(); distr.Start(); _proxy.Int.SayIAmHere("localhost", distrServer12); storage.Build(); storage.DbModule.AddDbModule(new TestDbInMemory()); storage.Start(); const int count = 50; for (int i = 0; i < count; i++) { var state = _proxy.Int.CreateSync(i, i); Assert.AreEqual(RequestState.Complete, state.State); } for (int i = 0; i < count; i++) { RequestDescription description; var read = _proxy.Int.Read(i, out description); Assert.AreEqual(i, read); Assert.AreEqual(RequestState.Complete, description.State); } for (int i = 0; i < count; i++) { var state = _proxy.Int.DeleteSync(i); Assert.AreEqual(RequestState.Complete, state.State); } for (int i = 0; i < count; i++) { RequestDescription description; _proxy.Int.Read(i, out description); Assert.AreEqual(RequestState.DataNotFound, description.State); } distr.Dispose(); storage.Dispose(); }
public TestProxyDistributorModule(AsyncProxyCache asyncProxyCache, ProxyNetModule net, QueueConfiguration queueConfiguration, ServerId local, AsyncTasksConfiguration asyncGetData, AsyncTasksConfiguration asyncPing) : base(asyncProxyCache, net, queueConfiguration, local, asyncGetData, asyncPing) { }