/// <summary> /// Creates a wrapper for the specified logger. /// </summary> /// <param name="logger">The logger.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="logger"/> is null.</exception> public RemoteLogger(ILogger logger) { if (logger == null) throw new ArgumentNullException("logger"); forwarder = new Forwarder(logger); }
/// <summary> /// Creates a remote message sink. /// </summary> /// <param name="messageSink">The message sink to wrap.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="messageSink"/> is null.</exception> public RemoteMessageSink(IMessageSink messageSink) { if (messageSink == null) throw new ArgumentNullException("messageSink"); forwarder = new Forwarder(messageSink); }
/// <summary> /// Creates a wrapper for the specified progress monitor. /// </summary> /// <param name="progressMonitor">The progress monitor.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="progressMonitor"/> is null.</exception> public RemoteProgressMonitor(IProgressMonitor progressMonitor) { if (progressMonitor == null) throw new ArgumentNullException("progressMonitor"); forwarder = new Forwarder(progressMonitor); RemotelyRegisterDispatcher(); }
static void Main() { Console.Title = "UPnP Forwarder"; using (var forward = new Forwarder()) { forward.BeginRun(); } }
public ActionResult AllCargoes() { List <Cargo> cargoes = db.Cargoes.Where(c => c.CarrierId < 1 || c.CarrierId == null).ToList(); List <CargoView> cargoViews = new List <CargoView>(); foreach (var cargo in cargoes) { CargoView cargoView = new CargoView(); cargoView.Id = cargo.CargoId; cargoView.Name = cargo.Name; cargoView.PricePerKilometer = cargo.PricePerKilometer; cargoView.Weight = cargo.Weight; Location fromLocation = db.Locations.Where(l => l.LocationId == cargo.FromLocationId).First(); Location forLocation = db.Locations.Where(l => l.LocationId == cargo.ForLocationId).First(); cargoView.FromLocation = fromLocation.Name; cargoView.ForLocation = forLocation.Name; Forwarder forwarder = db.Fowarders.Where(f => f.ForwarderId == cargo.ForwarderId).First(); cargoView.CargoType = cargo.CargoType.ToString(); cargoView.TransportType = cargo.TransportType.ToString(); cargoView.Forwarder = forwarder.Name; cargoViews.Add(cargoView); } return(View(cargoViews)); }
void InnerHandle(TransportMessage message) { var receivedMessage = new ImportSuccessfullyProcessedMessage(message); using (var childBuilder = Builder.CreateChildBuilder()) { PipelineExecutor.CurrentContext.Set(childBuilder); foreach (var enricher in childBuilder.BuildAll <IEnrichImportedMessages>()) { enricher.Enrich(receivedMessage); } var logicalMessage = LogicalMessageFactory.Create(typeof(ImportSuccessfullyProcessedMessage), receivedMessage); PipelineExecutor.InvokeLogicalMessagePipeline(logicalMessage); } if (Settings.ForwardAuditMessages == true) { Forwarder.Send(message, Settings.AuditLogQueue); } }
public static Dictionary <Guid, IQueuedHandler> CreateCoreWorkers( StandardComponents standardComponents, ProjectionsStandardComponents projectionsStandardComponents) { var coreTimeoutSchedulers = CreateTimeoutSchedulers(projectionsStandardComponents.ProjectionWorkerThreadCount); var coreQueues = new Dictionary <Guid, IQueuedHandler>(); while (coreQueues.Count < projectionsStandardComponents.ProjectionWorkerThreadCount) { var coreInputBus = new InMemoryBus("bus"); var coreQueue = QueuedHandler.CreateQueuedHandler(coreInputBus, "Projection Core #" + coreQueues.Count, groupName: "Projection Core"); var workerId = Guid.NewGuid(); var projectionNode = new ProjectionWorkerNode( workerId, standardComponents.Db, coreQueue, standardComponents.TimeProvider, coreTimeoutSchedulers[coreQueues.Count], projectionsStandardComponents.RunProjections); projectionNode.SetupMessaging(coreInputBus); var forwarder = new RequestResponseQueueForwarder( inputQueue: coreQueue, externalRequestQueue: standardComponents.MainQueue); // forwarded messages var coreOutput = projectionNode.CoreOutput; coreOutput.Subscribe <ClientMessage.ReadEvent>(forwarder); coreOutput.Subscribe <ClientMessage.ReadStreamEventsBackward>(forwarder); coreOutput.Subscribe <ClientMessage.ReadStreamEventsForward>(forwarder); coreOutput.Subscribe <ClientMessage.ReadAllEventsForward>(forwarder); coreOutput.Subscribe <ClientMessage.WriteEvents>(forwarder); coreOutput.Subscribe <ClientMessage.DeleteStream>(forwarder); if (projectionsStandardComponents.RunProjections >= ProjectionType.System) { var slaveProjectionResponseWriter = projectionNode.SlaveProjectionResponseWriter; coreOutput.Subscribe <PartitionMeasuredOutput>(slaveProjectionResponseWriter); coreOutput.Subscribe <PartitionProcessingProgressOutput>(slaveProjectionResponseWriter); coreOutput.Subscribe <PartitionProcessingResultOutput>(slaveProjectionResponseWriter); coreOutput.Subscribe <ReaderSubscriptionManagement.SpoolStreamReading>(slaveProjectionResponseWriter); coreOutput.Subscribe( Forwarder.Create <AwakeServiceMessage.SubscribeAwake>(standardComponents.MainQueue)); coreOutput.Subscribe( Forwarder.Create <AwakeServiceMessage.UnsubscribeAwake>(standardComponents.MainQueue)); } coreOutput.Subscribe <TimerMessage.Schedule>(standardComponents.TimerService); coreOutput.Subscribe(Forwarder.Create <Message>(coreQueue)); // forward all coreInputBus.Subscribe(new UnwrapEnvelopeHandler()); coreQueues.Add(workerId, coreQueue); } var queues = coreQueues.Select(v => v.Value).Cast <IPublisher>().ToArray(); var coordinator = new ProjectionCoreCoordinator( projectionsStandardComponents.RunProjections, coreTimeoutSchedulers, queues, projectionsStandardComponents.MasterOutputBus, new PublishEnvelope(projectionsStandardComponents.MasterInputQueue, crossThread: true)); coordinator.SetupMessaging(projectionsStandardComponents.MasterMainBus); projectionsStandardComponents.MasterMainBus.Subscribe( Forwarder.CreateBalancing <FeedReaderMessage.ReadPage>(coreQueues.Values.Cast <IPublisher>().ToArray())); return(coreQueues); }
internal override MethodInfo GetMethodOnTypeDefinition() { return(Forwarder.GetMethodOnTypeDefinition()); }
public DistributeMessagesBasedOnHeader(string localPartitionKey, Forwarder forwarder) { this.localPartitionKey = localPartitionKey; this.forwarder = forwarder; }
public override MethodImplAttributes GetMethodImplementationFlags() { return(Forwarder.GetMethodImplementationFlags()); }
internal override int GetGenericMethodArgumentCount() { return(Forwarder.GetGenericMethodArgumentCount()); }
public override bool __TryGetFieldOffset(out int offset) { return(Forwarder.__TryGetFieldOffset(out offset)); }
public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal) { return(Forwarder.__TryGetFieldMarshal(out fieldMarshal)); }
public void SetupMessaging(IBus coreInputBus) { coreInputBus.Subscribe(_subscriptionDispatcher .CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>()); coreInputBus.Subscribe(_subscriptionDispatcher .CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>()); coreInputBus.Subscribe( _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>()); coreInputBus.Subscribe(_subscriptionDispatcher .CreateSubscriber <EventReaderSubscriptionMessage.PartitionEofReached>()); coreInputBus.Subscribe(_subscriptionDispatcher .CreateSubscriber <EventReaderSubscriptionMessage.PartitionDeleted>()); coreInputBus.Subscribe(_subscriptionDispatcher .CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>()); coreInputBus.Subscribe(_subscriptionDispatcher .CreateSubscriber <EventReaderSubscriptionMessage.SubscriptionStarted>()); coreInputBus.Subscribe(_subscriptionDispatcher .CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>()); coreInputBus.Subscribe(_subscriptionDispatcher .CreateSubscriber <EventReaderSubscriptionMessage.ReaderAssignedReader>()); coreInputBus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.Failed>()); coreInputBus.Subscribe(_feedReaderService); if (_runProjections >= ProjectionType.System) { coreInputBus.Subscribe <ProjectionCoreServiceMessage.StartCore>(_projectionCoreService); coreInputBus.Subscribe <ProjectionCoreServiceMessage.StopCore>(_projectionCoreService); coreInputBus.Subscribe <ProjectionCoreServiceMessage.StopCoreTimeout>(_projectionCoreService); coreInputBus.Subscribe <ProjectionCoreServiceMessage.CoreTick>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionManagementMessage.CreateAndPrepare>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionManagementMessage.CreatePrepared>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionManagementMessage.Dispose>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionManagementMessage.Start>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionManagementMessage.LoadStopped>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionManagementMessage.Stop>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionManagementMessage.Kill>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionManagementMessage.GetState>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionManagementMessage.GetResult>(_projectionCoreService); coreInputBus.Subscribe <ClientMessage.ReadStreamEventsForwardCompleted>(_ioDispatcher.ForwardReader); coreInputBus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_ioDispatcher.BackwardReader); coreInputBus.Subscribe <ClientMessage.ReadEventCompleted>(_ioDispatcher.EventReader); coreInputBus.Subscribe <ClientMessage.WriteEventsCompleted>(_ioDispatcher.Writer); coreInputBus.Subscribe <ClientMessage.DeleteStreamCompleted>(_ioDispatcher.StreamDeleter); coreInputBus.Subscribe <IODispatcherDelayedMessage>(_ioDispatcher.Awaker); coreInputBus.Subscribe <IODispatcherDelayedMessage>(_ioDispatcher); coreInputBus.Subscribe <CoreProjectionProcessingMessage.CheckpointCompleted>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionProcessingMessage.CheckpointLoaded>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionProcessingMessage.RestartRequested>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionProcessingMessage.Failed>(_projectionCoreService); coreInputBus.Subscribe <CoreProjectionStatusMessage.Suspended>(_projectionCoreService); //NOTE: message forwarding is set up outside (for Read/Write events) // Forward messages back to projection manager coreInputBus.Subscribe( Forwarder.Create <ProjectionManagementMessage.Command.ControlMessage>(_leaderOutputBus)); coreInputBus.Subscribe( Forwarder.Create <CoreProjectionStatusMessage.CoreProjectionStatusMessageBase>(_leaderOutputBus)); coreInputBus.Subscribe( Forwarder.Create <CoreProjectionStatusMessage.DataReportBase>(_leaderOutputBus)); } coreInputBus.Subscribe <ReaderCoreServiceMessage.StartReader>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderCoreServiceMessage.StopReader>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionManagement.Subscribe>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionManagement.Unsubscribe>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionManagement.Pause>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionManagement.Resume>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionMessage.CommittedEventDistributed>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderIdle>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderStarting>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderEof>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionEof>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionDeleted>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionMessage.EventReaderNotAuthorized>(_eventReaderCoreService); coreInputBus.Subscribe <ReaderSubscriptionMessage.Faulted>(_eventReaderCoreService); //NOTE: message forwarding is set up outside (for Read/Write events) }
private static async Task MainAsync() { var instrumentationKey = Environment.GetEnvironmentVariable("Payments.InstrumentationKey", EnvironmentVariableTarget.Process); var license = Environment.GetEnvironmentVariable("NServiceBus.License", EnvironmentVariableTarget.Process); var ordersConnectionString = Environment.GetEnvironmentVariable("Orders.ConnectionString", EnvironmentVariableTarget.Process); var paymentsConnectionString = Environment.GetEnvironmentVariable("Payments.ConnectionString", EnvironmentVariableTarget.Process); System.Net.ServicePointManager.DefaultConnectionLimit = Int32.MaxValue; TelemetryConfiguration.Active.InstrumentationKey = instrumentationKey; var telemetryClient = new TelemetryClient(); var defaultFactory = LogManager.Use <DefaultFactory>(); defaultFactory.Level(LogLevel.Info); var endpointConfig = new EndpointConfiguration("Payments"); if (!string.IsNullOrEmpty(license)) { endpointConfig.License(license); } endpointConfig.UsePersistence <InMemoryPersistence>(); endpointConfig.SendFailedMessagesTo("error"); var transport = endpointConfig.UseTransport <AzureServiceBusTransport>(); transport.ConnectionString(paymentsConnectionString); var topology = transport.UseForwardingTopology(); var factories = transport.MessagingFactories(); var receivers = transport.MessageReceivers(); var perReceiverConcurrency = 10; var numberOfReceivers = 2; // Premium messaging has 2 partitions var globalConcurrency = numberOfReceivers * perReceiverConcurrency; endpointConfig.LimitMessageProcessingConcurrencyTo(globalConcurrency); factories.NumberOfMessagingFactoriesPerNamespace(numberOfReceivers * 2); //Bus receiver, bus sender transport.NumberOfClientsPerEntity(numberOfReceivers); factories.BatchFlushInterval(TimeSpan.FromMilliseconds(100)); receivers.PrefetchCount(1000); // The more we prefetch, the better the throughput will be, needs to be balanced though as you can only pull so many messages per batch topology.NumberOfEntitiesInBundle(1); // Only use 1 bundle topic, there is no benefit to using more and Particular are going to remove this support moving forward transport.Transactions(TransportTransactionMode.ReceiveOnly); // Use peek lock, vastly quicker than transport.BrokeredMessageBodyType(SupportedBrokeredMessageBodyTypes.Stream); // Need to use this for non-NSB integrations - will be what Particular use moving forward too transport.TransportType(TransportType.Amqp); // Use this rather than netmessaging, allows more connections to the namespace and is an open standard // See here for a better example of this that handles ungraceful shutdowns - https://github.com/Particular/docs.particular.net/blob/master/samples/application-insights/Metrics_1/Endpoint/ApplicationInsightsFeature.cs var metricOptions = endpointConfig.EnableMetrics(); metricOptions.RegisterObservers(context => { foreach (var duration in context.Durations) { duration.Register(observer: durationLength => telemetryClient.TrackMetric(new MetricTelemetry(duration.Name, durationLength.TotalMilliseconds))); } foreach (var signal in context.Signals) { signal.Register(observer: () => telemetryClient.TrackEvent(new EventTelemetry(signal.Name))); } }); var endpoint = await Endpoint.Start(endpointConfig).ConfigureAwait(false); var forwarderConfig = new ForwarderConfiguration( new ForwarderSourceConfiguration(500, () => CreateMessageReceiver(ordersConnectionString, "Payments")), new ForwarderDestinationConfiguration("Payments", () => CreateMessageForwarder(paymentsConnectionString, "Payments"))) .UsingLogger(new Logger(LogManager.GetLogger <Forwarder>())) .WithConcurrencyOf(3); var forwarder = new Forwarder(forwarderConfig); await CreateSubscriptionEntitiesIfRequired(ordersConnectionString, "Returns", "Payments"); forwarder.Start(); }
private void grdView_CellDoubleClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e) { fwd = xC.xtDB.fwdDB.selectByPk1(grdView.Sheets[0].Cells[e.Row, colID].Value == null ? "" : grdView.Sheets[0].Cells[e.Row, colID].Value.ToString()); setControl(); setEnable(false); }
public ForwarderSpec() { forwarder = new Forwarder(); }
public static void AddServerStreamingMethod <T>(ServerServiceDefinitionBuilder builder, Method <Void, T> method, Forwarder <T> forwarder) where T : class { builder.AddMethod(method, async(Void _, IServerStreamWriter <T> responseStream, ServerCallContext context) => { await forwarder.Subscribe(async reader => { while (context.CancellationToken.IsCancellationRequested == false) { var success = false; try { var x = await reader.ReadAsync(); await responseStream.WriteAsync(x); success = true; } catch (OperationCanceledException) { } if (success == false) { break; } } }); }); }
public TQueryResult Process <TQueryResult, TQuery>( PerformanceCounterEnum indexNumberCounterName, TQuery query, MessageContext messageContext, IndexStoreContext storeContext, MultiIndexIdQueryProcessor <TQueryResult> processor) where TQueryResult : BaseMultiIndexIdQueryResult, new() where TQuery : BaseMultiIndexIdQuery <TQueryResult> { if ((query.IndexIdList == null) || (query.IndexIdList.Count == 0)) { throw new Exception("Remote query index list is null or count is 0, type id is " + messageContext.TypeId); } // increment the performance counter PerformanceCounters.Instance.SetCounterValue( indexNumberCounterName, messageContext.TypeId, query.IndexIdList.Count); bool compressOption = storeContext.GetCompressOption(messageContext.TypeId); int numberOfClusters = storeContext.NumClustersInGroup; int myClusterPosition = storeContext.MyClusterPosition; List <TQueryResult> resultList = new List <TQueryResult>(); IPrimaryRelayMessageQuery localQuery; TQueryResult finalResult = null; TQueryResult localResult = null; TQuery localIndexQuery; List <IPrimaryRelayMessageQuery> queryList = query.SplitQuery( numberOfClusters, myClusterPosition, out localQuery); // send remote messages async, then run the local queries int remoteQueryCount = queryList.Count; if (remoteQueryCount == 0) // when there is no remote query { if (localQuery != null) { localIndexQuery = (TQuery)localQuery; finalResult = processor.Process(localIndexQuery, messageContext, storeContext); } } else { long endCount = 0; RelayMessage[] remoteQueryMessages = new RelayMessage[numberOfClusters]; TQueryResult[] queryResultArray = new TQueryResult[numberOfClusters]; Forwarder forwardingComponent = (Forwarder)storeContext.ForwarderComponent; using (AutoResetEvent evt = new AutoResetEvent(false)) { AsyncCallback callback = asyncResult => { try { forwardingComponent.EndHandleMessage(asyncResult); TQueryResult remoteResult = new TQueryResult(); int index = (int)asyncResult.AsyncState; remoteQueryMessages[index].GetObject <TQueryResult>(remoteResult); queryResultArray[index] = remoteResult; } catch (Exception ex) { LoggingUtil.Log.ErrorFormat( "Failed to get inter-cluster query result : {0}", ex); } finally { if (Interlocked.Increment(ref endCount) == remoteQueryCount) { evt.Set(); } } }; for (int i = 0; i < remoteQueryCount; i++) { try { TQuery myRemoteQuery = (TQuery)queryList[i]; myRemoteQuery.ExcludeData = true; // compose query message RelayMessage queryMsg = RelayMessage.GetQueryMessageForQuery( messageContext.TypeId, compressOption, myRemoteQuery); queryMsg.IsInterClusterMsg = true; remoteQueryMessages[myRemoteQuery.PrimaryId] = queryMsg; forwardingComponent.BeginHandleMessage(queryMsg, myRemoteQuery.PrimaryId, callback); } catch (Exception ex) { LoggingUtil.Log.ErrorFormat("Exception in Calling BeginHandleMessage : {0}", ex); // increment the end count since the exception caught, the async call is not successful if (Interlocked.Increment(ref endCount) == remoteQueryCount) { evt.Set(); } } } try { // handle local query using the local process if (localQuery != null) { localIndexQuery = (TQuery)localQuery; localResult = processor.Process(localIndexQuery, messageContext, storeContext); } } catch (Exception ex) { LoggingUtil.Log.ErrorFormat("Exception in getting local query result : {0}", ex); } // using infinite as timeout here, the timeout is already handled at the forwarder layer if (evt.WaitOne(IndexStoreContext.Instance.RemoteClusteredQueryTimeOut, true) == false) { LoggingUtil.Log.Error("Wait handler in remote clustered query didnt get signaled within the timeout period"); } if (localResult != null) { queryResultArray[storeContext.MyClusterPosition] = localResult; } } // end of using // convert the array to list for the merge processing for (int i = 0; i < numberOfClusters; i++) { if (queryResultArray[i] != null) { resultList.Add(queryResultArray[i]); } } // merge query results finalResult = query.MergeResults(resultList); } // end of else // retrieve the data GetDataItems(query.FullDataIdInfo, query.ExcludeData, messageContext, storeContext, finalResult); return(finalResult); }
private void SetupMessaging( TFChunkDb db, QueuedHandler mainQueue, ISubscriber mainBus, TimerService timerService, ITimeProvider timeProvider, IHttpForwarder httpForwarder, HttpService[] httpServices, IPublisher networkSendQueue, RunProjections runProjections) { _coreQueues = new List <QueuedHandler>(); _managerInputBus = new InMemoryBus("manager input bus"); _managerInputQueue = new QueuedHandler(_managerInputBus, "Projections Master"); while (_coreQueues.Count < _projectionWorkerThreadCount) { var coreInputBus = new InMemoryBus("bus"); var coreQueue = new QueuedHandler( coreInputBus, "Projection Core #" + _coreQueues.Count, groupName: "Projection Core"); var projectionNode = new ProjectionWorkerNode(db, coreQueue, timeProvider, runProjections); projectionNode.SetupMessaging(coreInputBus); var forwarder = new RequestResponseQueueForwarder( inputQueue: coreQueue, externalRequestQueue: mainQueue); // forwarded messages projectionNode.CoreOutput.Subscribe <ClientMessage.ReadEvent>(forwarder); projectionNode.CoreOutput.Subscribe <ClientMessage.ReadStreamEventsBackward>(forwarder); projectionNode.CoreOutput.Subscribe <ClientMessage.ReadStreamEventsForward>(forwarder); projectionNode.CoreOutput.Subscribe <ClientMessage.ReadAllEventsForward>(forwarder); projectionNode.CoreOutput.Subscribe <ClientMessage.WriteEvents>(forwarder); if (runProjections >= RunProjections.System) { projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.StateReport>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.ResultReport>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.StatisticsReport>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.Started>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.Stopped>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.Faulted>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.Prepared>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>( _managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <ProjectionManagementMessage.ControlMessage>(_managerInputQueue)); } projectionNode.CoreOutput.Subscribe <TimerMessage.Schedule>(timerService); projectionNode.CoreOutput.Subscribe(Forwarder.Create <Message>(coreQueue)); // forward all coreInputBus.Subscribe(new UnwrapEnvelopeHandler()); _coreQueues.Add(coreQueue); } _managerInputBus.Subscribe( Forwarder.CreateBalancing <FeedReaderMessage.ReadPage>(_coreQueues.Cast <IPublisher>().ToArray())); _projectionManagerNode = ProjectionManagerNode.Create( db, _managerInputQueue, httpForwarder, httpServices, networkSendQueue, _coreQueues.Cast <IPublisher>().ToArray(), runProjections); _projectionManagerNode.SetupMessaging(_managerInputBus); { var forwarder = new RequestResponseQueueForwarder( inputQueue: _managerInputQueue, externalRequestQueue: mainQueue); _projectionManagerNode.Output.Subscribe <ClientMessage.ReadEvent>(forwarder); _projectionManagerNode.Output.Subscribe <ClientMessage.ReadStreamEventsBackward>(forwarder); _projectionManagerNode.Output.Subscribe <ClientMessage.ReadStreamEventsForward>(forwarder); _projectionManagerNode.Output.Subscribe <ClientMessage.WriteEvents>(forwarder); _projectionManagerNode.Output.Subscribe( Forwarder.Create <ProjectionManagementMessage.RequestSystemProjections>(mainQueue)); _projectionManagerNode.Output.Subscribe(Forwarder.Create <Message>(_managerInputQueue)); _projectionManagerNode.Output.Subscribe <TimerMessage.Schedule>(timerService); // self forward all mainBus.Subscribe(Forwarder.Create <SystemMessage.StateChangeMessage>(_managerInputQueue)); _managerInputBus.Subscribe(new UnwrapEnvelopeHandler()); } }
private void SetUpCoreServices( Guid workerId, IBus bus, IPublisher inputQueue, InMemoryBus output_, ISingletonTimeoutScheduler timeoutScheduler) { var output = (output_ ?? inputQueue); ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000); var readerService = new EventReaderCoreService( output, _ioDispatcher, 10, writerCheckpoint, runHeadingReader: true, faultOutOfOrderProjections: true); _subscriptionDispatcher = new ReaderSubscriptionDispatcher(inputQueue); bus.Subscribe( _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>()); bus.Subscribe( _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>()); bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>()); bus.Subscribe( _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionEofReached>()); bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionDeleted>()); bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>()); bus.Subscribe( _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.SubscriptionStarted>()); bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>()); bus.Subscribe( _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ReaderAssignedReader>()); var ioDispatcher = new IODispatcher(output, new PublishEnvelope(inputQueue), true); // var coreServiceCommandReader = new ProjectionCoreServiceCommandReader( // output, // ioDispatcher, // workerId.ToString("N")); var coreService = new ProjectionCoreService( workerId, inputQueue, output, _subscriptionDispatcher, _timeProvider, ioDispatcher, timeoutScheduler); bus.Subscribe <CoreProjectionManagementMessage.CreateAndPrepare>(coreService); bus.Subscribe <CoreProjectionManagementMessage.CreatePrepared>(coreService); bus.Subscribe <CoreProjectionManagementMessage.Dispose>(coreService); bus.Subscribe <CoreProjectionManagementMessage.Start>(coreService); bus.Subscribe <CoreProjectionManagementMessage.LoadStopped>(coreService); bus.Subscribe <CoreProjectionManagementMessage.Stop>(coreService); bus.Subscribe <CoreProjectionManagementMessage.Kill>(coreService); bus.Subscribe <CoreProjectionManagementMessage.GetState>(coreService); bus.Subscribe <CoreProjectionManagementMessage.GetResult>(coreService); bus.Subscribe <CoreProjectionProcessingMessage.CheckpointCompleted>(coreService); bus.Subscribe <CoreProjectionProcessingMessage.CheckpointLoaded>(coreService); bus.Subscribe <CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(coreService); bus.Subscribe <CoreProjectionProcessingMessage.RestartRequested>(coreService); bus.Subscribe <CoreProjectionProcessingMessage.Failed>(coreService); bus.Subscribe <ClientMessage.ReadStreamEventsForwardCompleted>(ioDispatcher.ForwardReader); bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(ioDispatcher.BackwardReader); bus.Subscribe <ClientMessage.WriteEventsCompleted>(ioDispatcher.Writer); bus.Subscribe <ClientMessage.DeleteStreamCompleted>(ioDispatcher.StreamDeleter); bus.Subscribe <IODispatcherDelayedMessage>(ioDispatcher.Awaker); bus.Subscribe <IODispatcherDelayedMessage>(ioDispatcher); bus.Subscribe <ProjectionCoreServiceMessage.StartCore>(coreService); bus.Subscribe <ProjectionCoreServiceMessage.StopCore>(coreService); bus.Subscribe <ReaderCoreServiceMessage.StartReader>(readerService); bus.Subscribe <ReaderCoreServiceMessage.StopReader>(readerService); bus.Subscribe <ProjectionCoreServiceMessage.CoreTick>(coreService); bus.Subscribe <ReaderSubscriptionMessage.CommittedEventDistributed>(readerService); bus.Subscribe <ReaderSubscriptionMessage.EventReaderEof>(readerService); bus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionEof>(readerService); bus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionDeleted>(readerService); bus.Subscribe <ReaderSubscriptionMessage.EventReaderNotAuthorized>(readerService); bus.Subscribe <ReaderSubscriptionMessage.EventReaderIdle>(readerService); bus.Subscribe <ReaderSubscriptionMessage.EventReaderStarting>(readerService); bus.Subscribe <ReaderSubscriptionManagement.Pause>(readerService); bus.Subscribe <ReaderSubscriptionManagement.Resume>(readerService); bus.Subscribe <ReaderSubscriptionManagement.Subscribe>(readerService); bus.Subscribe <ReaderSubscriptionManagement.Unsubscribe>(readerService); if (output_ != null) { bus.Subscribe(new UnwrapEnvelopeHandler()); output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.StateReport>(GetInputQueue())); output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.ResultReport>(GetInputQueue())); output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.StatisticsReport>(GetInputQueue())); output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Started>(GetInputQueue())); output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Stopped>(GetInputQueue())); output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Faulted>(GetInputQueue())); output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Prepared>(GetInputQueue())); output_.Subscribe( Forwarder.Create <ProjectionManagementMessage.Command.ControlMessage>(GetInputQueue())); output_.Subscribe(Forwarder.Create <AwakeServiceMessage.SubscribeAwake>(GetInputQueue())); output_.Subscribe(Forwarder.Create <AwakeServiceMessage.UnsubscribeAwake>(GetInputQueue())); output_.Subscribe(Forwarder.Create <Message>(inputQueue)); // forward all var forwarder = new RequestResponseQueueForwarder( inputQueue: inputQueue, externalRequestQueue: GetInputQueue()); // forwarded messages output_.Subscribe <ClientMessage.ReadEvent>(forwarder); output_.Subscribe <ClientMessage.ReadStreamEventsBackward>(forwarder); output_.Subscribe <ClientMessage.ReadStreamEventsForward>(forwarder); output_.Subscribe <ClientMessage.ReadAllEventsForward>(forwarder); output_.Subscribe <ClientMessage.WriteEvents>(forwarder); } }
/// <summary> /// Initializes the reload config. /// </summary> /// <param name="config">The config.</param> /// <param name="isInit">if set to <c>true</c> [is init].</param> internal void InitializeReloadConfig(RelayNodeConfig config, bool isInit) { #region Set Component Configs if (config == null) { Exception ex = new Exception("Unable to Initialize/Reload Config for CacheIndexV3Store because RelayNodeConfig is null"); LoggingUtil.Log.Error(ex.Message); throw ex; } Interlocked.Exchange(ref nodeConfig, config); Interlocked.Exchange(ref storageConfiguration, InitializeConfig(nodeConfig)); #endregion #region Setup Forwarder if (ForwarderComponent == null) { ForwarderComponent = new Forwarder(); ForwarderComponent.Initialize(config, null); } else { ForwarderComponent.ReloadConfig(config); } #endregion #region Init/Reload Component if (IndexStorageComponent == null) { IndexStorageComponent = InitializeStorageComponent(storageConfiguration.BerkeleyDbConfig); } else { ReloadStorageComponent(storageConfiguration.BerkeleyDbConfig, IndexStorageComponent); } #endregion #region init memoryPool if (this.myMemoryPool == null) { this.myMemoryPool = new MemoryStreamPool( storageConfiguration.CacheIndexV3StorageConfig.MemPoolItemInitialSizeInBytes, ResourcePool.ResourcePool <MemoryStream> .InfiniteReuse, storageConfiguration.CacheIndexV3StorageConfig.MemPoolMinItemNumber); } #region init DataMembers Interlocked.Exchange(ref relatedTypeIds, InitializeRelatedTypeIds(nodeConfig)); Interlocked.Exchange(ref compressOptions, InitializeCompressOptions(nodeConfig)); InitializeClusterInfo(out myClusterPosition, out numClustersInGroup, out myZone); LockingUtil.Instance.InitializeLockerObjects(storageConfiguration.CacheIndexV3StorageConfig.LockMultiplier, numClustersInGroup); LegacySerializationUtil.Instance.InitializeLegacySerializtionTypes(nodeConfig.TypeSettings, storageConfiguration.CacheIndexV3StorageConfig.SupportLegacySerialization); #region init performance counters List <short> typeIdList = new List <short>(); foreach (IndexTypeMapping indexTypeMapping in storageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection) { typeIdList.Add(indexTypeMapping.TypeId); } // get the max type id short maxTypeId = config.TypeSettings.MaxTypeId; // initialize or re-initialize performance counters, // counter category will also be created if it is not there PerformanceCounters.Instance.InitializeCounters( config.TransportSettings.ListenPort, typeIdList, maxTypeId, isInit); #endregion #region Set HashCollections Interlocked.Exchange(ref tagHashCollection, InitializeTagHashCollection(storageConfiguration)); Interlocked.Exchange(ref stringHashCollection, InitializeStringHashCollection(storageConfiguration)); #endregion #endregion #region Init Domain Specific Config DomainSpecificConfig = new DomainSpecificConfig { StreamRecencyConfig = ConfigurationManager.GetSection("StreamRecencyConfig") as StreamRecencyConfig }; #endregion }
public override void __GetDataFromRVA(byte[] data, int offset, int length) { Forwarder.__GetDataFromRVA(data, offset, length); }
/* * private static void ShowPostsOf(string user, PostDesc[] posts) { * Logger.Fatal(user + " recebeu " + posts.Length + " mensagens:"); * for (int i = 0; i < posts.Length; i++) { * Logger.Fatal(i + ") " + posts[i].from + ": " + posts[i].message); * } * Logger.Fatal("\n"); * } */ private static void GetService(Type type) { // propriedades geradas automaticamente ServiceProperty autoProp = new ServiceProperty("openbus.component.interface", Repository.GetRepositoryID(type)); // propriedade definida pelo servidor hello ServiceProperty prop = new ServiceProperty("offer.domain", "Interoperability Tests"); ServiceProperty[] properties = { autoProp, prop }; List <ServiceOfferDesc> offers = Utils.FindOffer(ORBInitializer.Context.OfferRegistry, properties, 1, 10, 1); foreach (ServiceOfferDesc serviceOfferDesc in offers) { try { MarshalByRefObject obj = serviceOfferDesc.service_ref.getFacet( Repository.GetRepositoryID(type)); if (obj == null) { Logger.Fatal( "Não foi possível encontrar uma faceta com esse nome."); continue; } if (type == typeof(Messenger)) { Messenger facet = obj as Messenger; if (facet != null) { _messenger = facet; return; } } if (type == typeof(Forwarder)) { Forwarder facet = obj as Forwarder; if (facet != null) { _forwarder = facet; return; } } if (type == typeof(Broadcaster)) { Broadcaster facet = obj as Broadcaster; if (facet != null) { _broadcaster = facet; return; } } } catch (TRANSIENT) { Logger.Fatal( "Uma das ofertas obtidas é de um cliente inativo. Tentando a próxima."); } } Assert.Fail("Um servidor do tipo " + type + " não foi encontrado."); }
public override object GetRawConstantValue() { return(Forwarder.GetRawConstantValue()); }
public ToArgsQueue(Forwarder <FooArgs> fooChannel, Forwarder <BarArgs> barChannel, Forwarder <BazArgs> bazChannel) { m_fooChannel = fooChannel; m_barChannel = barChannel; m_bazChannel = bazChannel; }
public override string ToString() { return(Forwarder.ToString()); }
public DistributeMessagesBasedOnPayload(string localPartitionKey, Forwarder forwarder, Func <object, string> mapper) { this.localPartitionKey = localPartitionKey; this.forwarder = forwarder; this.mapper = mapper; }
public override MethodBody GetMethodBody() { return(Forwarder.GetMethodBody()); }
private void SetupMessaging( TFChunkDb db, QueuedHandler mainQueue, InMemoryBus mainBus, TimerService timerService, HttpService httpService) { _coreQueues = new List <QueuedHandler>(); _managerInputBus = new InMemoryBus("manager input bus"); _managerInputQueue = new QueuedHandler(_managerInputBus, "ProjectionManager"); while (_coreQueues.Count < _projectionWorkerThreadCount) { var coreInputBus = new InMemoryBus("bus"); var coreQueue = new QueuedHandler(coreInputBus, "ProjectionCoreQueue #" + _coreQueues.Count); var projectionNode = new ProjectionWorkerNode(db, coreQueue); projectionNode.SetupMessaging(coreInputBus); var forwarder = new RequestResponseQueueForwarder( inputQueue: coreQueue, externalRequestQueue: mainQueue); // forwarded messages projectionNode.CoreOutput.Subscribe <ClientMessage.ReadEvent>(forwarder); projectionNode.CoreOutput.Subscribe <ClientMessage.ReadStreamEventsBackward>(forwarder); projectionNode.CoreOutput.Subscribe <ClientMessage.ReadStreamEventsForward>(forwarder); projectionNode.CoreOutput.Subscribe <ClientMessage.ReadAllEventsForward>(forwarder); projectionNode.CoreOutput.Subscribe <ClientMessage.WriteEvents>(forwarder); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.StateReport>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.StatisticsReport>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.Started>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.Stopped>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.Faulted>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe( Forwarder.Create <CoreProjectionManagementMessage.Prepared>(_managerInputQueue)); projectionNode.CoreOutput.Subscribe(timerService); projectionNode.CoreOutput.Subscribe(Forwarder.Create <Message>(coreQueue)); // forward all coreInputBus.Subscribe(new UnwrapEnvelopeHandler()); _coreQueues.Add(coreQueue); } _projectionManagerNode = ProjectionManagerNode.Create( db, _managerInputQueue, httpService, _coreQueues.Cast <IPublisher>().ToArray()); _projectionManagerNode.SetupMessaging(_managerInputBus); { var forwarder = new RequestResponseQueueForwarder( inputQueue: _managerInputQueue, externalRequestQueue: mainQueue); _projectionManagerNode.Output.Subscribe <ClientMessage.ReadEvent>(forwarder); _projectionManagerNode.Output.Subscribe <ClientMessage.ReadStreamEventsBackward>(forwarder); _projectionManagerNode.Output.Subscribe <ClientMessage.ReadStreamEventsForward>(forwarder); _projectionManagerNode.Output.Subscribe <ClientMessage.WriteEvents>(forwarder); _projectionManagerNode.Output.Subscribe(Forwarder.Create <Message>(_managerInputQueue)); // self forward all mainBus.Subscribe(Forwarder.Create <SystemMessage.StateChangeMessage>(_managerInputQueue)); _managerInputBus.Subscribe(new UnwrapEnvelopeHandler()); } }
public override MethodInfo GetGenericMethodDefinition() { return(Forwarder.GetGenericMethodDefinition()); }
internal override IList <CustomAttributeData> GetCustomAttributesData(Type attributeType) { return(Forwarder.GetCustomAttributesData(attributeType)); }
internal override int GetCurrentToken() { return(Forwarder.GetCurrentToken()); }
static void Main(string[] args) { string[] inputs; int myTeamId = int.Parse(Console .ReadLine()); // if 0 you need to score on the right of the map, if 1 you need to score on the left var game = new Game(); var master = new Forwarder() { IsMasterPlayer = true, Game = game }; var slave = new Forwarder() { IsMasterPlayer = false, Companion = master, Game = game }; master.Companion = slave; // game loop while (true) { List <GameObject> snaffles = new List <GameObject>(); List <GameObject> bludgers = new List <GameObject>(); inputs = Console.ReadLine().Split(' '); int myScore = int.Parse(inputs[0]); int myMagic = int.Parse(inputs[1]); inputs = Console.ReadLine().Split(' '); int opponentScore = int.Parse(inputs[0]); int opponentMagic = int.Parse(inputs[1]); game.MyMagic = myMagic; game.MyScore = myScore; game.OpponentMagic = opponentMagic; game.OpponentScore = opponentScore; int entities = int.Parse(Console.ReadLine()); // number of entities still in game for (int i = 0; i < entities; i++) { snaffles = new List <GameObject>(); bludgers = new List <GameObject>(); inputs = Console.ReadLine().Split(' '); int entityId = int.Parse(inputs[0]); // entity identifier string entityType = inputs[1]; // "WIZARD", "OPPONENT_WIZARD" or "SNAFFLE" (or "BLUDGER" after first league) int x = int.Parse(inputs[2]); // position int y = int.Parse(inputs[3]); // position int vx = int.Parse(inputs[4]); // velocity int vy = int.Parse(inputs[5]); // velocity int state = int.Parse(inputs[6]); // 1 if the wizard is holding a Snaffle, 0 otherwise switch (entityType) { case "WIZARD": if (entityId % 2 == 0) { master.X = x; master.Y = y; master.VX = vx; master.VY = vy; master.Holding = state == 1; } else { slave.X = x; slave.Y = y; slave.VX = vx; slave.VY = vy; slave.Holding = state == 1; } break; case "SNAFFLE": snaffles.Add( new GameObject() { Id = entityId, X = x, Y = y, VX = vx, VY = vy }); break; case "BLUDGER": bludgers.Add( new GameObject() { Id = entityId, X = x, Y = y, VX = vx, VY = vy }); break; } } master.DoSomething(snaffles, bludgers, myTeamId); slave.DoSomething(snaffles, bludgers, myTeamId); } }