Example #1
0
 protected SmugglerBase(DatabaseSmugglerOptions options, DatabaseSmugglerNotifications notifications, IDatabaseSmugglerSource source, IDatabaseSmugglerDestination destination)
 {
     Options       = options;
     Notifications = notifications;
     Source        = source;
     Destination   = destination;
 }
Example #2
0
 public DatabaseSmuggler(DatabaseSmugglerOptions options, IDatabaseSmugglerSource source, IDatabaseSmugglerDestination destination)
 {
     _options       = options;
     _source        = source;
     _destination   = destination;
     _notifications = new DatabaseSmugglerNotifications();
 }
Example #3
0
        private async Task ProcessSourceAsync(IDatabaseSmugglerSource source, DatabaseSmugglerOperationState state, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(source.DisplayName) == false)
            {
                Notifications.ShowProgress("Processing source: {0}", source.DisplayName);
            }

            var maxEtags = await source
                           .FetchCurrentMaxEtagsAsync(cancellationToken)
                           .ConfigureAwait(false);

            while (true)
            {
                var type = await source
                           .GetNextSmuggleTypeAsync(cancellationToken)
                           .ConfigureAwait(false);

                switch (type)
                {
                case SmuggleType.None:
                    return;

                case SmuggleType.Index:
                    await new IndexSmuggler(_options, _notifications, source, _destination)
                    .SmuggleAsync(state, cancellationToken)
                    .ConfigureAwait(false);
                    continue;

                case SmuggleType.Document:
                    await new DocumentSmuggler(_options, _notifications, source, _destination, maxEtags)
                    .SmuggleAsync(state, cancellationToken)
                    .ConfigureAwait(false);
                    continue;

                case SmuggleType.Transformer:
                    await new TransformerSmuggler(_options, _notifications, source, _destination)
                    .SmuggleAsync(state, cancellationToken)
                    .ConfigureAwait(false);
                    continue;

                case SmuggleType.DocumentDeletion:
                    await new DocumentDeletionsSmuggler(_options, _notifications, source, _destination, maxEtags)
                    .SmuggleAsync(state, cancellationToken)
                    .ConfigureAwait(false);
                    continue;

                case SmuggleType.Identity:
                    await new IdentitySmuggler(_options, _notifications, source, _destination)
                    .SmuggleAsync(state, cancellationToken)
                    .ConfigureAwait(false);
                    continue;

                case SmuggleType.Attachment:
                    await new AttachmentSmuggler(_options, _notifications, source, _destination)
                    .SmuggleAsync(state, cancellationToken)
                    .ConfigureAwait(false);
                    continue;

                case SmuggleType.AttachmentDeletion:
                    await new AttachmentDeletionsSmuggler(_options, _notifications, source, _destination)
                    .SmuggleAsync(state, cancellationToken)
                    .ConfigureAwait(false);
                    continue;

                default:
                    throw new NotSupportedException(type.ToString());
                }
            }
        }
Example #4
0
        private static async Task <DatabaseSmugglerOperationState> GetOperationStateAsync(DatabaseSmugglerOptions options, IDatabaseSmugglerSource source, IDatabaseSmugglerDestination destination, CancellationToken cancellationToken)
        {
            DatabaseSmugglerOperationState state = null;

            if (destination.SupportsOperationState)
            {
                state = await destination
                        .LoadOperationStateAsync(options, cancellationToken)
                        .ConfigureAwait(false);
            }

            if (state == null)
            {
                state = new DatabaseSmugglerOperationState
                {
                    LastDocsEtag      = options.StartDocsEtag,
                    LastDocDeleteEtag = options.StartDocsDeletionEtag,
                };
            }

            Debug.Assert(state.LastDocsEtag != null);
            Debug.Assert(state.LastDocDeleteEtag != null);

            return(state);
        }
Example #5
0
 public AttachmentSmuggler(DatabaseSmugglerOptions options, DatabaseSmugglerNotifications notifications, IDatabaseSmugglerSource source, IDatabaseSmugglerDestination destination)
     : base(options, notifications, source, destination)
 {
 }
Example #6
0
 public TransformerSmuggler(DatabaseSmugglerOptions options, DatabaseSmugglerNotifications notifications, IDatabaseSmugglerSource source, IDatabaseSmugglerDestination destination)
     : base(options, notifications, source, destination)
 {
 }
Example #7
0
 public DocumentSmuggler(DatabaseSmugglerOptions options, DatabaseSmugglerNotifications notifications, IDatabaseSmugglerSource source, IDatabaseSmugglerDestination destination, DatabaseLastEtagsInfo maxEtags)
     : base(options, notifications, source, destination)
 {
     _maxEtags = maxEtags;
     _patcher  = new SmugglerJintHelper();
     _patcher.Initialize(options);
 }
Example #8
0
 public DocumentDeletionsSmuggler(DatabaseSmugglerOptions options, DatabaseSmugglerNotifications notifications, IDatabaseSmugglerSource source, IDatabaseSmugglerDestination destination, DatabaseLastEtagsInfo maxEtags)
     : base(options, notifications, source, destination)
 {
     _maxEtags = maxEtags;
 }