public void onDestinationQueryCallback(DestinationInfo[] destinations) { destinationInfo = destinations; MessageBox.Show("Loaded Destinations..."); _flightService.LoadFromCity(); _flightService.LoadToCity(); }
private void QueryAccess(DestinationInfo dInfo, UserAccount account, Vector3 position) { foreach (AuthorizationServiceInterface authService in m_AuthorizationServices) { authService.QueryAccess(account.Principal, dInfo.ID); } }
public ActiveMQTempDestination CreateTemporaryDestination(bool topic) { ActiveMQTempDestination destination = null; if (topic) { destination = new ActiveMQTempTopic( info.ConnectionId.Value + ":" + Interlocked.Increment(ref temporaryDestinationCounter)); } else { destination = new ActiveMQTempQueue( info.ConnectionId.Value + ":" + Interlocked.Increment(ref temporaryDestinationCounter)); } DestinationInfo command = new DestinationInfo(); command.ConnectionId = ConnectionId; command.OperationType = DestinationInfo.ADD_OPERATION_TYPE; // 0 is add command.Destination = destination; this.SyncRequest(command); destination.Connection = this; return(destination); }
// // Un-marshal an object instance from the data input stream // public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn) { base.LooseUnmarshal(wireFormat, o, dataIn); DestinationInfo info = (DestinationInfo)o; info.ConnectionId = (ConnectionId)LooseUnmarshalCachedObject(wireFormat, dataIn); info.Destination = (ActiveMQDestination)LooseUnmarshalCachedObject(wireFormat, dataIn); info.OperationType = dataIn.ReadByte(); info.Timeout = LooseUnmarshalLong(wireFormat, dataIn); if (dataIn.ReadBoolean()) { short size = dataIn.ReadInt16(); BrokerId[] value = new BrokerId[size]; for (int i = 0; i < size; i++) { value[i] = (BrokerId)LooseUnmarshalNestedObject(wireFormat, dataIn); } info.BrokerPath = value; } else { info.BrokerPath = null; } }
private async void TryRemoveOutMessageInfo(DestinationInfo destInfo, uint messageId) { var curMthdName = this.MyNameOfMethod(e => e.TryRemoveOutMessageInfo(null, 0)); try { using (_stateHelper.GetFuncWrapper()) { using (await destInfo.OutMessagesDbLockSem.GetDisposable().ConfigureAwait(false)) { if (destInfo.OutMessagesDb.ContainsKey(messageId)) { destInfo.OutMessagesDb.Remove(messageId); } } } } catch (WrongDisposableObjectStateException) { } catch (Exception exc) { _log.Error("{0} unexpected error '{1}'", curMthdName, exc.ToString()); } }
public void Dispatch(MessageDispatch messageDispatch) { // Auto ack messages when we reach 75% of the prefetch deliveredCounter++; if (deliveredCounter > (0.75 * this.info.PrefetchSize)) { try { MessageAck ack = new MessageAck(); ack.AckType = (byte)AckType.ConsumedAck; ack.FirstMessageId = messageDispatch.Message.MessageId; ack.MessageCount = deliveredCounter; this.connection.Oneway(ack); this.deliveredCounter = 0; } catch (Exception e) { this.connection.OnAsyncException(e); } } DestinationInfo destInfo = messageDispatch.Message.DataStructure as DestinationInfo; if (destInfo != null) { ProcessDestinationInfo(destInfo); } else { // This can happen across networks Tracer.Debug("Unexpected message was dispatched to the AdvisoryConsumer: " + messageDispatch); } }
private void ProcessDestinationInfo(DestinationInfo destInfo) { ActiveMQDestination dest = destInfo.Destination; if (!dest.IsTemporary) { return; } ActiveMQTempDestination tempDest = dest as ActiveMQTempDestination; if (destInfo.OperationType == DestinationInfo.ADD_OPERATION_TYPE) { if (Tracer.IsDebugEnabled) { Tracer.Debug("AdvisoryConsumer adding: " + tempDest); } this.connection.AddTempDestination(tempDest); } else if (destInfo.OperationType == DestinationInfo.REMOVE_OPERATION_TYPE) { if (Tracer.IsDebugEnabled) { Tracer.Debug("AdvisoryConsumer removing: " + tempDest); } this.connection.RemoveTempDestination(tempDest); } }
public async Task SetPassiveAsync_DestinationBecameUnhealthy_SetUnhealthyAndScheduleReactivation() { var destination = new DestinationInfo("destination0"); destination.Health.Active = DestinationHealth.Healthy; destination.Health.Passive = DestinationHealth.Healthy; var cluster = CreateCluster(passive: true, active: false, destination); using var timerFactory = new TestTimerFactory(); var updater = new DestinationHealthUpdater(timerFactory, new Mock <ILogger <DestinationHealthUpdater> >().Object); await updater.SetPassiveAsync(cluster, destination, DestinationHealth.Unhealthy, TimeSpan.FromSeconds(2)); timerFactory.VerifyTimer(0, 2000); Assert.Empty(cluster.DynamicState.HealthyDestinations); Assert.Equal(DestinationHealth.Healthy, destination.Health.Active); Assert.Equal(DestinationHealth.Unhealthy, destination.Health.Passive); timerFactory.FireAll(); Assert.Equal(DestinationHealth.Healthy, destination.Health.Active); Assert.Equal(DestinationHealth.Unknown, destination.Health.Passive); Assert.Equal(1, cluster.DynamicState.HealthyDestinations.Count); Assert.Same(destination, cluster.DynamicState.HealthyDestinations[0]); timerFactory.AssertTimerDisposed(0); }
public void EnumerateDestinations() { Console.WriteLine("Listing all Destinations on Broker:"); IDestination dest = session.GetTopic(ALLDEST_ADVISORY_DESTINATION); using (IMessageConsumer consumer = session.CreateConsumer(dest)) { IMessage advisory; while ((advisory = consumer.Receive(TimeSpan.FromMilliseconds(2000))) != null) { ActiveMQMessage amqMsg = advisory as ActiveMQMessage; if (amqMsg.DataStructure != null) { DestinationInfo info = amqMsg.DataStructure as DestinationInfo; if (info != null) { string destType = info.Destination.IsTopic ? "Topic" : "Qeue"; destType = info.Destination.IsTemporary ? "Temporary" + destType : destType; Console.WriteLine(" " + destType + ": " + info.Destination.ToString()); } } } } Console.WriteLine("Listing Complete."); }
public void EnumerateTopics() { Console.WriteLine("Listing all Topics on Broker:"); IDestination dest = session.GetTopic(TOPIC_ADVISORY_DESTINATION); using (IMessageConsumer consumer = session.CreateConsumer(dest)) { IMessage advisory; while ((advisory = consumer.Receive(TimeSpan.FromMilliseconds(2000))) != null) { ActiveMQMessage amqMsg = advisory as ActiveMQMessage; if (amqMsg.DataStructure != null) { DestinationInfo info = amqMsg.DataStructure as DestinationInfo; if (info != null) { Console.WriteLine(" Topic: " + info.Destination.ToString()); } } } } Console.WriteLine("Listing Complete."); }
private IReverseProxyFeature GetProxyFeature(ClusterConfig clusterConfig, DestinationInfo destination) { var result = new Mock <IReverseProxyFeature>(MockBehavior.Strict); result.SetupProperty(p => p.SelectedDestination, destination); result.SetupProperty(p => p.ClusterConfig, clusterConfig); return(result.Object); }
public void RequestProxied(ClusterInfo cluster, DestinationInfo destination, HttpContext context) { var error = context.Features.Get <IProxyErrorFeature>(); var newHealth = EvaluateProxiedRequest(cluster, destination, error != null); var reactivationPeriod = cluster.Config.Options.HealthCheck.Passive.ReactivationPeriod ?? _defaultReactivationPeriod; _healthUpdater.SetPassive(cluster, destination, newHealth, reactivationPeriod); }
public void RemoveItem(DestinationInfo item) { using (var db = new DataBase()) { db.Remove(item); db.SaveChanges(); } }
private IReverseProxyFeature GetProxyFeature(ClusterConfig clusterConfig, DestinationInfo destination) { return(new ReverseProxyFeature() { ProxiedDestination = destination, ClusterSnapshot = clusterConfig, }); }
private async Task <DestinationInfo> GetDestinationInfo(CancellationToken cancellationToken) { SecretWrapper secret = await _secretStore.GetSecretAsync(_exportJobRecord.SecretName, cancellationToken); DestinationInfo destinationInfo = JsonConvert.DeserializeObject <DestinationInfo>(secret.SecretValue); return(destinationInfo); }
public CreateExportRequest(Uri requestUri, string destinationType, string destinationConnectionString) { EnsureArg.IsNotNull(requestUri, nameof(requestUri)); EnsureArg.IsNotNullOrWhiteSpace(destinationType, nameof(destinationType)); EnsureArg.IsNotNullOrWhiteSpace(destinationConnectionString, nameof(destinationConnectionString)); RequestUri = requestUri; DestinationInfo = new DestinationInfo(destinationType, destinationConnectionString); }
private IReverseProxyFeature GetProxyFeature(ClusterInfo clusterInfo, DestinationInfo destination) { return(new ReverseProxyFeature() { ProxiedDestination = destination, ClusterSnapshot = clusterInfo.Config, RouteSnapshot = new RouteConfig(new ProxyRoute(), clusterInfo, HttpTransformer.Default), }); }
protected void CreateTemporaryDestination(ActiveMQDestination tempDestination) { DestinationInfo command = new DestinationInfo(); command.ConnectionId = Connection.ConnectionId; command.OperationType = DestinationInfo.ADD_OPERATION_TYPE; // 0 is add command.Destination = tempDestination; this.connection.SyncRequest(command); }
// Get destination info from secret store, create appropriate export client and connect to destination. private async Task GetDestinationInfoAndConnectAsync(CancellationToken cancellationToken) { SecretWrapper secret = await _secretStore.GetSecretAsync(_exportJobRecord.SecretName, cancellationToken); DestinationInfo destinationInfo = JsonConvert.DeserializeObject <DestinationInfo>(secret.SecretValue); _exportDestinationClient = _exportDestinationClientFactory.Create(destinationInfo.DestinationType); await _exportDestinationClient.ConnectAsync(destinationInfo.DestinationConnectionString, cancellationToken, _exportJobRecord.Id); }
protected void DestroyTemporaryDestination(ActiveMQDestination tempDestination) { DestinationInfo command = new DestinationInfo(); command.ConnectionId = connection.ConnectionId; command.OperationType = 1; // 1 is remove command.Destination = tempDestination; connection.SyncRequest(command); }
protected void CreateTemporaryDestination(ActiveMQDestination tempDestination) { DestinationInfo command = new DestinationInfo(); command.ConnectionId = connection.ConnectionId; command.OperationType = 0; // 0 is add command.Destination = tempDestination; connection.SyncRequest(command); }
/// <summary> /// Delete a destination (Queue, Topic, Temp Queue, Temp Topic). /// </summary> public void DeleteDestination(IDestination destination) { DestinationInfo command = new DestinationInfo(); command.ConnectionId = Connection.ConnectionId; command.OperationType = DestinationInfo.REMOVE_OPERATION_TYPE; // 1 is remove command.Destination = destination; this.DoSend(command); }
public void PickDestination_WithoutDestinations_Null() { var loadBalancer = Create <LoadBalancer>(); var destinations = new DestinationInfo[0]; var options = new ClusterConfig.ClusterLoadBalancingOptions((LoadBalancingMode)(-1)); var result = loadBalancer.PickDestination(destinations, in options); Assert.Null(result); }
public void DestionationInfoReadOnlyList() { var destinationInfo = new DestinationInfo("destionation2"); IReadOnlyList <DestinationInfo> list = destinationInfo; Assert.Equal(1, list.Count); Assert.Same(destinationInfo, list[0]); Assert.Throws <IndexOutOfRangeException>(() => list[1]); }
public void DeleteDestination(IDestination destination) { DestinationInfo command = new DestinationInfo(); command.ConnectionId = this.ConnectionId; command.OperationType = DestinationInfo.REMOVE_OPERATION_TYPE; // 1 is remove command.Destination = (ActiveMQDestination)destination; this.Oneway(command); }
/// <summary>Moves the Thing through.</summary> /// <param name="thingToMove">The thing to move.</param> /// <returns>Returns true if the move was successful, false if not.</returns> public bool MoveThrough(Thing thingToMove) { // If the thing isn't currently mobile, bail. var movableBehavior = thingToMove.Behaviors.FindFirst <MovableBehavior>(); if (movableBehavior == null) { // TODO: Add messaging to thingToMove? return(false); } // Find the target location to be reached from here. DestinationInfo destinationInfo = GetDestinationFrom(thingToMove.Parent.Id); if (destinationInfo == null) { // There was no destination reachable from the thing's starting location. return(false); } // If the target location hasn't been cached already, try to do so now. if (destinationInfo.CachedTarget == null || destinationInfo.CachedTarget.Target == null) { Thing newTarget = ThingManager.Instance.FindThing(destinationInfo.TargetID); destinationInfo.CachedTarget = new SimpleWeakReference <Thing>(newTarget); } // If the destination can't be found, abort. Thing destination = destinationInfo.CachedTarget.Target; if (destination == null) { // TODO: Add messaging to thingToMove? return(false); } string dir = destinationInfo.ExitCommand; var leaveContextMessage = new ContextualString(thingToMove, thingToMove.Parent) { ToOriginator = null, ToReceiver = $"{thingToMove.Name} moves {dir}.", ToOthers = $"{thingToMove.Name} moves {dir}.", }; var arriveContextMessage = new ContextualString(thingToMove, destination) { ToOriginator = $"You move {dir} to {destination.Name}.", ToReceiver = $"{thingToMove.Name} arrives, heading {dir}.", ToOthers = $"{thingToMove.Name} arrives, heading {dir}.", }; var leaveMessage = new SensoryMessage(SensoryType.Sight, 100, leaveContextMessage); var arriveMessage = new SensoryMessage(SensoryType.Sight, 100, arriveContextMessage); return(movableBehavior.Move(destination, Parent, leaveMessage, arriveMessage)); }
public void removeTempDestination(IDestination destination) { for (int i = tempDestinations.Count - 1; i >= 0; i--) { DestinationInfo di = tempDestinations[i]; if (di.Destination.Equals(destination)) { tempDestinations.RemoveAt(i); } } }
// // Write a object instance to data output stream // public override void LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut) { DestinationInfo info = (DestinationInfo)o; base.LooseMarshal(wireFormat, o, dataOut); LooseMarshalCachedObject(wireFormat, (DataStructure)info.ConnectionId, dataOut); LooseMarshalCachedObject(wireFormat, (DataStructure)info.Destination, dataOut); dataOut.Write(info.OperationType); LooseMarshalLong(wireFormat, info.Timeout, dataOut); LooseMarshalObjectArray(wireFormat, info.BrokerPath, dataOut); }
public void AffinitizeRequest_RequestIsNotAffinitized_SetAffinityKey() { var dataProtector = GetDataProtector(); var provider = new ProviderStub(dataProtector.Object, AffinityTestHelper.GetLogger <BaseSessionAffinityProvider <string> >().Object); var destination = new DestinationInfo("dest-A"); provider.AffinitizeRequest(new DefaultHttpContext(), _defaultOptions, destination); Assert.Equal("ZGVzdC1B", provider.LastSetEncryptedKey); var keyBytes = Encoding.UTF8.GetBytes(destination.DestinationId); dataProtector.Verify(p => p.Protect(It.Is <byte[]>(b => b.SequenceEqual(keyBytes))), Times.Once); }
// // Write a object instance to data output stream // public override void TightMarshal2(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut, BooleanStream bs) { base.TightMarshal2(wireFormat, o, dataOut, bs); DestinationInfo info = (DestinationInfo)o; TightMarshalCachedObject2(wireFormat, (DataStructure)info.ConnectionId, dataOut, bs); TightMarshalCachedObject2(wireFormat, (DataStructure)info.Destination, dataOut, bs); dataOut.Write(info.OperationType); TightMarshalLong2(wireFormat, info.Timeout, dataOut, bs); TightMarshalObjectArray2(wireFormat, info.BrokerPath, dataOut, bs); }
public override Response ProcessRemoveDestination(DestinationInfo info) { if (info != null && info.Destination.IsTemporary) { ConnectionState cs; if (connectionStates.TryGetValue(info.ConnectionId, out cs)) { cs.RemoveTempDestination(info.Destination); } } return(TRACKED_RESPONSE_MARKER); }
public void LoadFromCity() { cmbFrom.DisplayMember = "CityName"; cmbFrom.ValueMember = "CityCode"; DestinationInfo[] destinations = callback.destinationInfo; DestinationInfo[] newDestinations = new DestinationInfo[destinations.Length]; for (int i = 0; i < destinations.Length; i++) { DestinationInfo d = new DestinationInfo(); d.CityCode = destinations[i].CityCode; d.CityName = destinations[i].CityName; newDestinations[i] = d; } cmbFrom.DataSource = newDestinations; //ddFrom.DataBind(); }
public override DestinationInfo CreateDestinationInfo() { DestinationInfo info = new DestinationInfo(); info.IsOpenExternally = this.IsOpenExternally; info.TypeName = this.GetType().ToString(); info.Data = new string[] { ip.ToString(), prefixLength.ToString(), port.ToString() }; return info; }
private async void OnHandshakeStartReceived( HandshakeStartArgs handshakeStartArgs ) { try { using (_stateHelper.GetFuncWrapper()) { string fromDestination = handshakeStartArgs.Destination; if (_dropDestinations.Contains(fromDestination)) return; if (!SamHelper.IsDestinationStringValid(fromDestination)) return; DestinationInfo destinationInfo; using (await _destinationDbLockSem.GetDisposable().ConfigureAwait(false)) { if ( !_destinationDb.ContainsKey( handshakeStartArgs.Destination ) ) { destinationInfo = new DestinationInfo(); _destinationDb.Add( handshakeStartArgs.Destination, destinationInfo ); } else { destinationInfo = _destinationDb[ handshakeStartArgs.Destination ]; } } using (await destinationInfo.InMessagesDbLockSem.GetDisposable().ConfigureAwait(false)) { if ( destinationInfo.InMessagesDb.ContainsKey( handshakeStartArgs.MessageId ) ) { var inMessageInfo = destinationInfo.InMessagesDb[ handshakeStartArgs.MessageId ]; if ( inMessageInfo.Status == InMessageStatus.HandshakeReceived ) { await SendMessageStatus( fromDestination, handshakeStartArgs.MessageId, MessageStatusArgs.MessageStatusCode.HandshakeOk, 0 ).ConfigureAwait(false); return; } else if ( inMessageInfo.Status == InMessageStatus.AllBlocksReceived ) { await SendMessageStatus( fromDestination, handshakeStartArgs.MessageId, MessageStatusArgs.MessageStatusCode.AllBlocksReceived, inMessageInfo.BlocksReceivedCount ).ConfigureAwait(false); return; } else { await SendMessageStatus( fromDestination, handshakeStartArgs.MessageId, MessageStatusArgs .MessageStatusCode .HandshakeErrorDuplicatedId, inMessageInfo.BlocksReceivedCount ).ConfigureAwait(false); return; } } else { if ( handshakeStartArgs.MessageSize > _settings.MaxMesageLength ) { await SendMessageStatus( fromDestination, handshakeStartArgs.MessageId, MessageStatusArgs.MessageStatusCode .HandshakeErrorWrongTotalSize, 0 ).ConfigureAwait(false); return; } if (handshakeStartArgs.BlockSize > _settings.MaxBlockSize) { await SendMessageStatus( fromDestination, handshakeStartArgs.MessageId, MessageStatusArgs.MessageStatusCode .HandshakeErrorWrongBlockSize, 0 ).ConfigureAwait(false); return; } var inMessageInfo = new InMessageInfo( handshakeStartArgs.MessageSize, handshakeStartArgs.BlockSize, handshakeStartArgs.ReplyToMessageId, handshakeStartArgs.MessageKind, handshakeStartArgs.MessageHash ); if ( inMessageInfo.ReceivedDataChunkSizes[0] != handshakeStartArgs.FirstBlockData.Length ) { await SendMessageStatus( fromDestination, handshakeStartArgs.MessageId, MessageStatusArgs.MessageStatusCode .HandshakeErrorWrongBlockSize, 0 ).ConfigureAwait(false); return; } destinationInfo.InMessagesDb.Add( handshakeStartArgs.MessageId, inMessageInfo ); await SendMessageStatus( fromDestination, handshakeStartArgs.MessageId, MessageStatusArgs.MessageStatusCode.HandshakeOk, 0 ).ConfigureAwait(false); OnBlockSendReceived( new BlockSendArgs() { BlockData = handshakeStartArgs.FirstBlockData, BlockId = 0, Destination = handshakeStartArgs.Destination, MessageId = handshakeStartArgs.MessageId } ); return; } } } } catch (OperationCanceledException) { } catch (WrongDisposableObjectStateException) { } catch (Exception exc) { _log.Error( "OnHandshakeStartReceive" + " unexpected error '{0}'", exc.ToString() ); } }
public void onDestinationQueryCallback(DestinationInfo[] destinations) { destinationInfo = destinations; MessageBox.Show("Loaded Destinations..."); }
private async void TryRemoveOutMessageInfo(DestinationInfo destInfo, uint messageId) { var curMthdName = this.MyNameOfMethod(e => e.TryRemoveOutMessageInfo(null, 0)); try { using (_stateHelper.GetFuncWrapper()) { using (await destInfo.OutMessagesDbLockSem.GetDisposable().ConfigureAwait(false)) { if (destInfo.OutMessagesDb.ContainsKey(messageId)) destInfo.OutMessagesDb.Remove(messageId); } } } catch (WrongDisposableObjectStateException) { } catch (Exception exc) { _log.Error("{0} unexpected error '{1}'", curMthdName, exc.ToString()); } }
public TCPIPv6Destination(DestinationInfo info) { base.ip = IPAddress.Parse(info.Data[0]); base.prefixLength = Int32.Parse(info.Data[1]); base.port = UInt32.Parse(info.Data[2]); if (base.IsExternal) { base.isOpenExternally = info.IsOpenExternally; } }