internal void SetKind(TransportKind kind) { this.Kind = kind; switch (kind) { case TransportKind.EmperorFund: this.TitleText.Text = "进贡资金"; if (this.SourceArchitecture.jingongjianzhuliebiao() != null) { this.DestinationArchitecture = this.SourceArchitecture.jingongjianzhuliebiao()[0] as Architecture; } break; case TransportKind.EmperorFood: this.TitleText.Text = "进贡粮草"; if (this.SourceArchitecture.jingongjianzhuliebiao() != null) { this.DestinationArchitecture = this.SourceArchitecture.jingongjianzhuliebiao()[0] as Architecture; } break; case TransportKind.Fund: this.TitleText.Text = "运输资金"; break; case TransportKind.Food: this.TitleText.Text = "运输粮草"; break; } }
public ITransport GetTransportAt(IDestination destination, TransportKind transportKind) => _availableTransport.FirstOrDefault(transport => { var transportKindMatch = transport.Kind == transportKind; var transportAvailableAtMatch = transport.IsAvailableAt(destination); return(transportKindMatch && transportAvailableAtMatch); });
public override void MergeSlots(Pullenti.Ner.Referent obj, bool mergeStatistic = true) { base.MergeSlots(obj, mergeStatistic); List <TransportKind> kinds = new List <TransportKind>(); foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_KIND) { TransportKind ki = this._getKind((string)s.Value); if (!kinds.Contains(ki)) { kinds.Add(ki); } } } if (kinds.Count > 0) { if (kinds.Contains(TransportKind.Space)) { for (int i = Slots.Count - 1; i >= 0; i--) { if (Slots[i].TypeName == ATTR_KIND && this._getKind((string)Slots[i].Value) != TransportKind.Space) { Slots.RemoveAt(i); } } } } }
private void ShowDestinationFrame() { switch (this.Kind) { case TransportKind.Fund: case TransportKind.Food: this.TabListPlugin.InitialValues(this.SourceArchitecture.BelongedFaction.ArchitecturesExcluding(this.SourceArchitecture), null, 0, this.TitleText.Text); break; case TransportKind.EmperorFood: case TransportKind.EmperorFund: return; } this.TabListPlugin.SetListKindByName("Architecture", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.Architecture; this.GameFramePlugin.Function = FrameFunction.Transport; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; this.GameFramePlugin.SetOKFunction(delegate { this.DestinationArchitecture = this.TabListPlugin.SelectedItem as Architecture; }); this.GameFramePlugin.IsShowing = true; }
/// <summary> /// Initializes a new instance of the <see cref="RemoteExporterEndpoint"/> class. /// </summary> /// <param name="host">Host name used by the endpoint.</param> /// <param name="port">Port used by the endpoint.</param> /// <param name="transport">Tranport kind used by the endpoint.</param> /// <param name="streams">Endpoint streams.</param> public RemoteExporterEndpoint(string host, int port, TransportKind transport, IEnumerable <Stream> streams) : base(streams) { this.Host = host; this.Port = port; this.Transport = transport; }
private Route(IDestination start, IDestination end, TransportKind transportKind, int timeEstimate) { Start = start; End = end; TransportKind = transportKind; TimeEstimate = timeEstimate; }
public TransportTypeAttribute(TransportKind kind = TransportKind.ByValue, bool enablePublicMembersByDefault = true, string customTypescriptBaseClass = null, string customDtoName = null, bool isMethodCustomizationEnabled = false) { Kind = kind; EnablePublicMembersByDefault = enablePublicMembersByDefault; CustomTypescriptBaseClass = customTypescriptBaseClass; CustomDtoName = customDtoName; IsMethodCustomizationEnabled = isMethodCustomizationEnabled; }
static async Task _SendMessages(TransportKind transportKind, int messageCount) { Action <IHandlerActivator> configureSenderAdapter = _GetConfigureAdapterCallBack(transportKind, 1, 0); using (var sender = new MessageSender(transportKind.ToString(), configure: configureSenderAdapter)) { await sender.Send(messageCount); } }
// entry point for the server. The process can be terminated with process.StandardInput.WriteLine(). private void GenerateData(TransportKind transportKind) { using (var p = Pipeline.Create()) { using (var remote = new RemoteExporter(p, transportKind)) { var exporter = remote.Exporter; var generator = Generators.Range(p, 0, 100, TimeSpan.FromMilliseconds(1)); generator.Write(ServerDataStream, exporter); p.RunAsync(); Console.ReadLine(); } } }
public static async Task Run(TransportKind transportKind, int busCount = 1, int readParallelism = 4, int numberOfWorkers = 10, bool isLongRun = false) { int messageCount = _GetMeassageCount(transportKind); if (transportKind == TransportKind.SqlServer) { _PurgeInputQueue(); } if (transportKind == TransportKind.InMemory) { inMemNetwork = new InMemNetwork(); } var t1 = Task.Run(() => _SendMessages(transportKind, messageCount)); var t2 = Task.Run(() => _ReceiveMessages(transportKind, busCount, readParallelism, numberOfWorkers, messageCount, isLongRun)); await Task.WhenAll(t1, t2); }
/// <summary> /// Construct transport from `TransportKind`. /// </summary> /// <param name="kind">Kind of transport.</param> /// <returns>Transport instance.</returns> public static ITransport TransportOfKind(TransportKind kind) { switch (kind) { case TransportKind.NamedPipes: return(new NamedPipesTransport()); case TransportKind.Tcp: return(new TcpTransport()); case TransportKind.Udp: return(new UdpTransport()); default: throw new ArgumentException($"Unknown transport kind: {kind}"); } }
static async Task _ReceiveMessages(TransportKind transportKind, int busCount, int readParallelism, int numberOfWorkers, int messageCountToReceive, bool isLongRun) { Action <IHandlerActivator> configureReceiverAdapter = _GetConfigureAdapterCallBack(transportKind, readParallelism, 0); MessageReceiver.totalReceivedCount = 0; MessageReceiver[] messageReceivers = new MessageReceiver[busCount]; Task[] receiveTasks = new Task[busCount]; var tcs = new TaskCompletionSource <bool>(); for (int i = 0; i < busCount; ++i) { string name = $"{transportKind}:#{i + 1}"; messageReceivers[i] = new MessageReceiver(name, configure: configureReceiverAdapter, maxNumberOfWorkers: numberOfWorkers, messageCount: messageCountToReceive, tcs: tcs, isLongRun: isLongRun); } try { for (int i = 0; i < busCount; ++i) { receiveTasks[i] = messageReceivers[i].Receive(); } await Task.WhenAll(receiveTasks); await Task.Delay(1000); } finally { for (int i = 0; i < busCount; ++i) { try { messageReceivers[i].Dispose(); } catch (Exception ex) { Console.WriteLine($"Error disposing messageRecever: {ex.Message}"); } } } }
public Route Create(IDestination start, IDestination end, TransportKind transportKind, int routeEstimate) { if (start == end) { throw new ArgumentException("Route start and end destinations should be different."); } if (!_routeValidator.IsValidRoute(start, end)) { throw new ArgumentException($"{start.Name} -> {end.Name} is an invalid route."); } if (!_routeValidator.IsValidTransportTypeForRoute(start, end, transportKind)) { throw new ArgumentException("Invalid transport kind for the route."); } return(new Route(start, end, transportKind, routeEstimate)); }
private RemoteExporter(string name, string path, int port, TransportKind transport, long maxBytesPerSecond, double bytesPerSecondSmoothingWindowSeconds) { this.name = name; this.path = path; this.port = port; this.dataTransport = Transport.TransportOfKind(transport); this.maxBytesPerSecond = maxBytesPerSecond; this.bytesPerSecondSmoothingWindowSeconds = bytesPerSecondSmoothingWindowSeconds; this.metaClientThread = new Thread(new ThreadStart(this.AcceptMetaClientsBackground)) { IsBackground = true }; this.metaClientThread.Start(); this.dataClientThread = new Thread(new ThreadStart(this.AcceptDataClientsBackground)) { IsBackground = true }; this.dataClientThread.Start(); }
static Action <IHandlerActivator> _GetConfigureAdapterCallBack(TransportKind transportKind, int readParallelism, int numberOfWorkers) { return((adapter) => { var rebusConfigurer = Configure.With(adapter); rebusConfigurer.Logging(l => l.Console(Logging.LogLevel.Warn)); rebusConfigurer.Transport(t => { switch (transportKind) { case TransportKind.SqlServer: t.UseSqlServer(SqlServerConnectionString, QueueName); break; case TransportKind.FileSystem: t.UseFileSystem(FileSystemDirectory, QueueName); break; case TransportKind.InMemory: t.UseInMemoryTransport(inMemNetwork, QueueName); break; } }); bool isFastQueueReads = TransportKind.InMemory == transportKind; rebusConfigurer.Options(o => { o.SetNumberOfWorkers(numberOfWorkers); o.SetMaxReadParallelism(readParallelism); // if reading message from the queue is fast then it is better to use synchronous throttling // otherwise - asynchronous is better o.SetAsyncReadThrottling(!isFastQueueReads); }); rebusConfigurer.Start(); }); }
static int _GetMeassageCount(TransportKind transportKind) { int messageCount = 0; switch (transportKind) { case TransportKind.SqlServer: messageCount = 5000; break; case TransportKind.FileSystem: messageCount = 1000; break; case TransportKind.InMemory: messageCount = 200000; break; default: messageCount = 1000; break; } return(messageCount); }
private void ShowDestinationFrame() //代码未用 { switch (this.Kind) { case TransportKind.Fund: this.TabListPlugin.InitialValues(this.SourceArchitecture.jingongjianzhuliebiao(), null, 0, this.TitleText.Text); break; case TransportKind.Food: this.TabListPlugin.InitialValues(this.SourceArchitecture.RoutewayDestinationArchitectureList, null, 0, this.TitleText.Text); break; } this.TabListPlugin.SetListKindByName("Architecture", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.Architecture; this.GameFramePlugin.Function = FrameFunction.GetFacilityToBuild; //???????可能有BUG。 this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; this.GameFramePlugin.SetOKFunction(delegate { this.DestinationArchitecture = this.TabListPlugin.SelectedItem as Architecture; }); this.GameFramePlugin.IsShowing = true; }
public void SetKind(TransportKind kind) { this.transportDialog.SetKind(kind); }
//代码未用 private void ShowDestinationFrame() { switch (this.Kind) { case TransportKind.Fund: this.TabListPlugin.InitialValues(this.SourceArchitecture.jingongjianzhuliebiao(), null, 0, this.TitleText.Text); break; case TransportKind.Food: this.TabListPlugin.InitialValues(this.SourceArchitecture.RoutewayDestinationArchitectureList, null, 0, this.TitleText.Text); break; } this.TabListPlugin.SetListKindByName("Architecture", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.Architecture; this.GameFramePlugin.Function = FrameFunction.GetFacilityToBuild; //???????可能有BUG。 this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; this.GameFramePlugin.SetOKFunction(delegate { this.DestinationArchitecture = this.TabListPlugin.SelectedItem as Architecture; }); this.GameFramePlugin.IsShowing = true; }
internal void SetKind(TransportKind kind) { this.Kind = kind; switch (kind) { case TransportKind.Fund: this.TitleText.Text = "进贡资金"; if (this.SourceArchitecture.jingongjianzhuliebiao()!=null ) { this.DestinationArchitecture = this.SourceArchitecture.jingongjianzhuliebiao()[0] as Architecture; } break; case TransportKind.Food: this.TitleText.Text = "进贡粮草"; if (this.SourceArchitecture.jingongjianzhuliebiao() != null) { this.DestinationArchitecture = this.SourceArchitecture.jingongjianzhuliebiao()[0] as Architecture; } break; } }
/// <summary> /// Initializes a new instance of the <see cref="RemoteExporter"/> class. /// </summary> /// <param name="exporter">Exporter to be remoted.</param> /// <param name="port">TCP port on which to listen (default 11411).</param> /// <param name="transport">Transport kind to use.</param> /// <param name="maxBytesPerSecond">Maximum bytes/sec quota (default infinite).</param> /// <param name="bytesPerSecondSmoothingWindowSeconds">Smoothing window over which to compute bytes/sec (default 5 sec.).</param> public RemoteExporter(Exporter exporter, int port = DefaultPort, TransportKind transport = DefaultTransport, long maxBytesPerSecond = long.MaxValue, double bytesPerSecondSmoothingWindowSeconds = 5.0) : this(exporter.Name, exporter.Path, port, transport, maxBytesPerSecond, bytesPerSecondSmoothingWindowSeconds) { this.Exporter = exporter; }
/// <summary> /// Initializes a new instance of the <see cref="RemoteExporter"/> class. /// </summary> /// <param name="importer">Importer to be remoted.</param> /// <param name="transport">Transport kind to use.</param> public RemoteExporter(Importer importer, TransportKind transport) : this(importer, DefaultPort, transport) { }
/// <summary> /// Initializes a new instance of the <see cref="RemoteExporter"/> class. /// </summary> /// <param name="exporter">Exporter to be remoted.</param> /// <param name="transport">Transport kind to use.</param> public RemoteExporter(Exporter exporter, TransportKind transport) : this(exporter, DefaultPort, transport) { }
public void TransportKind_Should_Be_Valid_For_Given_Route(IDestination start, IDestination end, TransportKind transportKind) => Assert.Throws <ArgumentException>(() => _routeFactory.Create(start, end, transportKind, 1));
public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ = Pullenti.Ner.Core.ReferentsEqualType.WithinOneText) { TransportReferent tr = obj as TransportReferent; if (tr == null) { return(false); } TransportKind k1 = Kind; TransportKind k2 = tr.Kind; if (k1 != k2) { if (k1 == TransportKind.Space && tr.FindSlot(ATTR_TYPE, "КОРАБЛЬ", true) != null) { } else if (k2 == TransportKind.Space && this.FindSlot(ATTR_TYPE, "КОРАБЛЬ", true) != null) { k1 = TransportKind.Space; } else { return(false); } } Pullenti.Ner.Slot sl = this.FindSlot(ATTR_ORG, null, true); if (sl != null && tr.FindSlot(ATTR_ORG, null, true) != null) { if (tr.FindSlot(ATTR_ORG, sl.Value, false) == null) { return(false); } } sl = this.FindSlot(ATTR_GEO, null, true); if (sl != null && tr.FindSlot(ATTR_GEO, null, true) != null) { if (tr.FindSlot(ATTR_GEO, sl.Value, true) == null) { return(false); } } string s1 = this.GetStringValue(ATTR_NUMBER); string s2 = tr.GetStringValue(ATTR_NUMBER); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else { if (s1 != s2) { return(false); } s1 = this.GetStringValue(ATTR_NUMBER_REGION); s2 = tr.GetStringValue(ATTR_NUMBER_REGION); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else if (s1 != s2) { return(false); } } } } s1 = this.GetStringValue(ATTR_BRAND); s2 = tr.GetStringValue(ATTR_BRAND); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else if (s1 != s2) { return(false); } } s1 = this.GetStringValue(ATTR_MODEL); s2 = tr.GetStringValue(ATTR_MODEL); if (s1 != null || s2 != null) { if (s1 == null || s2 == null) { if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts) { return(false); } } else if (s1 != s2) { return(false); } } foreach (Pullenti.Ner.Slot s in Slots) { if (s.TypeName == ATTR_NAME) { if (tr.FindSlot(ATTR_NAME, s.Value, true) != null) { return(true); } } } if (s1 != null && s2 != null) { return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="RemoteExporter"/> class. /// </summary> /// <param name="importer">Importer to be remoted.</param> /// <param name="port">TCP port on which to listen (default 11411).</param> /// <param name="transport">Transport kind to use.</param> /// <param name="maxBytesPerSecond">Maximum bytes/sec quota (default infinite).</param> /// <param name="bytesPerSecondSmoothingWindowSeconds">Smoothing window over which to compute bytes/sec (default 5 sec.).</param> public RemoteExporter(Importer importer, int port = DefaultPort, TransportKind transport = DefaultTransport, long maxBytesPerSecond = long.MaxValue, double bytesPerSecondSmoothingWindowSeconds = 5.0) : this(importer.Name, importer.Path, port, transport, maxBytesPerSecond, bytesPerSecondSmoothingWindowSeconds) { // used to remote an existing store. this.Exporter remains null }
protected Transport(Binding binding, TransportKind kind) : base(binding) { m_TransportKind = kind; m_Glue = binding.Glue; binding._Register(this); }
/// <summary> /// Initializes a new instance of the <see cref="RemoteExporterEndpoint"/> class. /// </summary> /// <param name="host">Host name used by the endpoint.</param> /// <param name="port">Port used by the endpoint.</param> /// <param name="transport">Tranport kind used by the endpoint.</param> public RemoteExporterEndpoint(string host, int port, TransportKind transport) : this(host, port, transport, Enumerable.Empty <Stream>()) { }
internal bool Check(bool onAttach, bool brandisdoubt) { TransportKind ki = Kind; if (ki == TransportKind.Undefined) { return(false); } if (this.FindSlot(ATTR_NUMBER, null, true) != null) { if (this.FindSlot(ATTR_NUMBER_REGION, null, true) == null && (Slots.Count < 3)) { return(false); } return(true); } string model = this.GetStringValue(ATTR_MODEL); bool hasNum = false; if (model != null) { foreach (char s in model) { if (!char.IsLetter(s)) { hasNum = true; break; } } } if (ki == TransportKind.Auto) { if (this.FindSlot(ATTR_BRAND, null, true) != null) { if (onAttach) { return(true); } if (!hasNum && this.FindSlot(ATTR_TYPE, null, true) == null) { return(false); } if (brandisdoubt && model == null && !hasNum) { return(false); } return(true); } if (model != null && onAttach) { return(true); } return(false); } if (model != null) { if (!hasNum && ki == TransportKind.Fly && this.FindSlot(ATTR_BRAND, null, true) == null) { return(false); } return(true); } if (this.FindSlot(ATTR_NAME, null, true) != null) { string nam = this.GetStringValue(ATTR_NAME); if (ki == TransportKind.Fly && nam.StartsWith("Аэрофлот")) { return(false); } return(true); } if (ki == TransportKind.Train) { } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="RemoteExporter"/> class. /// </summary> /// <param name="pipeline">Pipeline to which to attach.</param> /// <param name="port">TCP port on which to listen (default 11411).</param> /// <param name="transport">Transport kind to use.</param> /// <param name="maxBytesPerSecond">Maximum bytes/sec quota (default infinite).</param> /// <param name="bytesPerSecondSmoothingWindowSeconds">Smoothing window over which to compute bytes/sec (default 5 sec.).</param> public RemoteExporter(Pipeline pipeline, int port = DefaultPort, TransportKind transport = DefaultTransport, long maxBytesPerSecond = long.MaxValue, double bytesPerSecondSmoothingWindowSeconds = 5.0) : this(PsiStore.Create(pipeline, $"RemoteExporter_{Guid.NewGuid().ToString()}", null, true), port, transport, maxBytesPerSecond, bytesPerSecondSmoothingWindowSeconds) { }
/// <summary> /// Initializes a new instance of the <see cref="RemoteExporter"/> class. /// </summary> /// <param name="pipeline">Pipeline to which to attach.</param> /// <param name="transport">Transport kind to use.</param> /// <param name="maxBytesPerSecond">Maximum bytes/sec quota (default infinite).</param> /// <param name="bytesPerSecondSmoothingWindowSeconds">Smoothing window over which to compute bytes/sec (default 5 sec.).</param> public RemoteExporter(Pipeline pipeline, TransportKind transport, long maxBytesPerSecond = long.MaxValue, double bytesPerSecondSmoothingWindowSeconds = 5.0) : this(pipeline, DefaultPort, transport, maxBytesPerSecond, bytesPerSecondSmoothingWindowSeconds) { }