public BulkInsertCommand(long id, StreamExposerContent stream, string nodeTag) { _stream = stream; _id = id; SelectedNodeTag = nodeTag; Timeout = TimeSpan.FromHours(12); // global max timeout }
public BulkInsertCommand(long id, StreamExposerContent stream, string nodeTag, bool skipOverwriteIfUnchanged) { _id = id; _stream = stream; SelectedNodeTag = nodeTag; _skipOverwriteIfUnchanged = skipOverwriteIfUnchanged; Timeout = TimeSpan.FromHours(12); // global max timeout }
public BulkInsertOperation(string database, IDocumentStore store, CancellationToken token = default(CancellationToken)) { _token = token; _requestExecutor = store.GetRequestExecutor(database); _resetContext = _requestExecutor.ContextPool.AllocateOperationContext(out _context); _streamExposerContent = new StreamExposerContent(); _generateEntityIdOnTheClient = new GenerateEntityIdOnTheClient(_requestExecutor.Conventions, entity => AsyncHelpers.RunSync(() => _requestExecutor.Conventions.GenerateDocumentIdAsync(database, entity))); }
public BulkInsertCommand(long id, StreamExposerContent stream) { _stream = stream; _id = id; Timeout = TimeSpan.FromHours(12); // global max timeout }
public BulkInsertOperation(string database, IDocumentStore store, CancellationToken token = default) { _disposeOnce = new DisposeOnceAsync <SingleAttempt>(async() => { try { Exception flushEx = null; if (_stream != null) { try { _currentWriter.Write(']'); _currentWriter.Flush(); await _asyncWrite.ConfigureAwait(false); ((MemoryStream)_currentWriter.BaseStream).TryGetBuffer(out var buffer); await _requestBodyStream.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, _token).ConfigureAwait(false); _compressedStream?.Dispose(); await _stream.FlushAsync(_token).ConfigureAwait(false); } catch (Exception e) { flushEx = e; } } _streamExposerContent.Done(); if (_operationId == -1) { // closing without calling a single store. return; } if (_bulkInsertExecuteTask != null) { try { await _bulkInsertExecuteTask.ConfigureAwait(false); } catch (Exception e) { await ThrowBulkInsertAborted(e, flushEx).ConfigureAwait(false); } } } finally { _streamExposerContent?.Dispose(); _resetContext.Dispose(); } }); _token = token; _conventions = store.Conventions; _requestExecutor = store.GetRequestExecutor(database); _resetContext = _requestExecutor.ContextPool.AllocateOperationContext(out _context); _currentWriter = new StreamWriter(new MemoryStream()); _backgroundWriter = new StreamWriter(new MemoryStream()); _streamExposerContent = new StreamExposerContent(); _defaultSerializer = _requestExecutor.Conventions.CreateSerializer(); _customEntitySerializer = _requestExecutor.Conventions.BulkInsert.TrySerializeEntityToJsonStream; _generateEntityIdOnTheClient = new GenerateEntityIdOnTheClient(_requestExecutor.Conventions, entity => AsyncHelpers.RunSync(() => _requestExecutor.Conventions.GenerateDocumentIdAsync(database, entity))); }