public bool Connect()
        {
            Endpoint = new KustoEndpoint();
            Endpoint.Authenticate();
            _failureQueryTime         = _instance.StartTime.ToUniversalTime();
            _tempContainerEnumerator  = Endpoint.IngestionResources.TempStorageContainers.GetEnumerator();
            _ingestionQueueEnumerator = Endpoint.IngestionResources.IngestionQueues.GetEnumerator();

            if (!_ingestionQueueEnumerator.MoveNext())
            {
                Log.Error($"problem with ingestion queues", Endpoint.IngestionResources);
                return(false);
            }

            if (!_tempContainerEnumerator.MoveNext())
            {
                Log.Error($"problem with temp container ", Endpoint.IngestionResources);
                return(false);
            }

            if (Config.IsKustoPurgeRequested())
            {
                Purge();
                return(false);
            }
            else if (Config.KustoRecreateTable)
            {
                PurgeMessages(Endpoint.TableName);

                if (!Endpoint.DropTable(Endpoint.TableName))
                {
                    return(false);
                }
            }
            else if (Config.Unique && Endpoint.HasTable(Endpoint.TableName))
            {
                _appendingToExistingTableUnique = true;
                Endpoint.Query($"['{Endpoint.TableName}']|distinct RelativeUri")
                .ForEach(x => IngestFileObjectsSucceeded.Add(relativeUri: x));
            }

            // monitor for new files to be uploaded
            if (_monitorTask == null)
            {
                _monitorTask = Task.Run((Action)QueueMonitor, _tokenSource.Token);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool Connect()
        {
            Endpoint = new KustoEndpoint(_config);
            Endpoint.Authenticate();
            _failureQueryTime = _instance.StartTime.ToUniversalTime();

            if (!PopulateQueueEnumerators())
            {
                return(false);
            }

            if (_config.IsKustoPurgeRequested())
            {
                Purge();
                return(false);
            }
            else if (_config.KustoRecreateTable)
            {
                PurgeMessages(Endpoint.TableName);

                if (!Endpoint.DropTable(Endpoint.TableName))
                {
                    return(false);
                }
            }
            else if (_config.Unique && Endpoint.HasTable(Endpoint.TableName))
            {
                _appendingToExistingTableUnique = true;
                List <string> existingUploads = Endpoint.Query($"['{Endpoint.TableName}']|distinct RelativeUri");
                foreach (string existingUpload in existingUploads)
                {
                    _instance.FileObjects.Add(new FileObject(existingUpload)
                    {
                        Status = FileStatus.existing
                    });
                }
            }

            // monitor for new files to be uploaded
            if (_monitorTask == null)
            {
                _monitorTask = Task.Run((Action)QueueMonitor, _tokenSource.Token);
            }

            return(true);
        }