private void OnTransformerChange(DocumentDatabase documentDatabase, TransformerChangeNotification notification)
        {
            var transformerName = notification.Name;
            switch (notification.Type)
            {
                case TransformerChangeTypes.TransformerAdded:
                    //if created transformer with the same name as deleted one, we should prevent its deletion replication
                    Database.TransactionalStorage.Batch(accessor =>
                        accessor.Lists.Remove(Constants.RavenReplicationTransformerTombstones, transformerName));

                    break;
                case TransformerChangeTypes.TransformerRemoved:
                    //If we don't have any destination to replicate to (we are probably slave node)
                    //we shouldn't keep a tombstone since we are not going to remove it anytime
                    //and keeping it prevents us from getting that transformer created again.
                    if (GetReplicationDestinations().Count == 0)
                        return;

                    var metadata = new RavenJObject
                    {
                        {Constants.RavenTransformerDeleteMarker, true},
                        {Constants.RavenReplicationSource, Database.TransactionalStorage.Id.ToString()},
                        {Constants.RavenReplicationVersion, ReplicationHiLo.NextId(Database)},
                        {"TransformerVersion", notification.Version }
                    };

                    Database.TransactionalStorage.Batch(accessor =>
                        accessor.Lists.Set(Constants.RavenReplicationTransformerTombstones, transformerName, metadata, UuidType.Transformers));
                    break;
            }
        }
 public void Send(TransformerChangeNotification transformerChangeNotification)
 {
     var onOnTransformerChangeNotification = OnTransformerChangeNotification;
     if (onOnTransformerChangeNotification != null)
     {
         onOnTransformerChangeNotification(transformerChangeNotification);
     }
 }
Beispiel #3
0
 public void Send(TransformerChangeNotification transformerChangeNotification)
 {
     OnTransformerChangeNotification(this, transformerChangeNotification);
     foreach (var connectionState in connections)
     {
         connectionState.Value.Send(transformerChangeNotification);
     }
 }
 public void RaiseNotifications(TransformerChangeNotification obj)
 {
     Database.TransportState.Send(obj);
     var handler = OnTransformerChange;
     if (handler != null) handler(Database, obj);
 }
Beispiel #5
0
        private void OnTransformerChange(DocumentDatabase documentDatabase, TransformerChangeNotification eventArgs)
        {
            switch (eventArgs.Type)
            {
                case TransformerChangeTypes.TransformerAdded:
                    //if created transformer with the same name as deleted one, we should prevent its deletion replication
                    docDb.TransactionalStorage.Batch(accessor => accessor.Lists.Remove(Constants.RavenReplicationTransformerTombstones, eventArgs.Name));
                    break;
                case TransformerChangeTypes.TransformerRemoved:
                    var metadata = new RavenJObject
                    {
                        {Constants.RavenTransformerDeleteMarker, true},
                        {Constants.RavenReplicationSource, docDb.TransactionalStorage.Id.ToString()},
                        {Constants.RavenReplicationVersion, ReplicationHiLo.NextId(docDb)}
                    };

                    docDb.TransactionalStorage.Batch(accessor => accessor.Lists.Set(Constants.RavenReplicationTransformerTombstones, eventArgs.Name, metadata, UuidType.Transformers));
                    break;
            }
        }
 public void RaiseNotifications(TransformerChangeNotification obj)
 {
     Database.TransportState.Send(obj);
 }
Beispiel #7
0
 public void Send(TransformerChangeNotification transformerChangeNotification)
 {
     if (watchAllTransformers > 0)
     {
         Enqueue(new { Value = transformerChangeNotification, Type = "TransformerChangeNotification" });
     }
 }