public bool TryUpdateTopicDirectory(string tenant, string product, string component, Topic topic)
        {
            try
            {
                if (Directory.Exists(TenantLocations.GetTopicDirectory(tenant, product, component, topic.Name)) != true)
                {
                    Directory.CreateDirectory(TenantLocations.GetTopicDirectory(tenant, product, component, topic.Name));
                }
                if (Directory.Exists(TenantLocations.GetConsumerRootDirectory(tenant, product, component, topic.Name)) != true)
                {
                    Directory.CreateDirectory(TenantLocations.GetConsumerRootDirectory(tenant, product, component, topic.Name));
                }
                if (Directory.Exists(TenantLocations.GetProducerRootDirectory(tenant, product, component, topic.Name)) != true)
                {
                    Directory.CreateDirectory(TenantLocations.GetProducerRootDirectory(tenant, product, component, topic.Name));
                }
                if (Directory.Exists(TenantLocations.GetTopicLogRootDirectory(tenant, product, component, topic.Name)) != true)
                {
                    Directory.CreateDirectory(TenantLocations.GetTopicLogRootDirectory(tenant, product, component, topic.Name));
                }
                if (Directory.Exists(TenantLocations.GetIndexRootDirectory(tenant, product, component, topic.Name)) != true)
                {
                    Directory.CreateDirectory(TenantLocations.GetIndexRootDirectory(tenant, product, component, topic.Name));
                }
                if (Directory.Exists(TenantLocations.GetMessageRootDirectory(tenant, product, component, topic.Name)) != true)
                {
                    Directory.CreateDirectory(TenantLocations.GetMessageRootDirectory(tenant, product, component, topic.Name));
                }

                if (File.Exists(TenantLocations.GetTopicConfigFile(tenant, product, component, topic.Name)) != true)
                {
                    // Because this call is triggered by XNode in only in an agent in storage, it doesn't need to go thru a queue.
                    TenantWriter.WriteTopicConfigFile(tenant, product, component, topic);
                    return(true);
                }

                // Do not update the topic schema
                //Topic fromFile = TenantReader.ReadTopicConfigFile(tenant, product, component, topic.Name);
                //fromFile.Schema = topic.Schema;
                //TenantWriter.WriteTopicConfigFile(tenant, product, component, fromFile);

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
 private void TenantConfigiFileProcessor()
 {
     while (tenantConfigFilesQueue.Count > 0)
     {
         Tenant tenant;
         bool   isTenantReturned = tenantConfigFilesQueue.TryDequeue(out tenant);
         if (isTenantReturned == true)
         {
             TenantWriter.WriteTenantConfigFile(tenant);
         }
         else
         {
             logger.LogError("Processing of tenant failed, couldn't Dequeue");
         }
     }
     IsTenantConfigFilesWorking = false;
 }
        public bool TryCreateComponentDirectory(string tenant, string product, Component component)
        {
            try
            {
                if (Directory.Exists(TenantLocations.GetComponentDirectory(tenant, product, component.Name)) == false)
                {
                    Directory.CreateDirectory(TenantLocations.GetComponentDirectory(tenant, product, component.Name));
                    Directory.CreateDirectory(TenantLocations.GetTopicRootDirectory(tenant, product, component.Name));

                    // Because this call is triggered by XNode in only in an agent in storage, it doesn't need to go thru a queue.
                    TenantWriter.WriteComponentConfigFile(tenant, product, component);
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
 private void TenantLoggingProcessor()
 {
     while (tenantLogsQueue.Count > 0)
     {
         try
         {
             TenantLog tenantLog;
             bool      isLogReturned = tenantLogsQueue.TryDequeue(out tenantLog);
             if (isLogReturned == true)
             {
                 TenantWriter.WriteInTenantLog(tenantLog.Tenant, tenantLog.Log);
             }
             else
             {
                 logger.LogError("Logging requests on tenant failed");
             }
         }
         catch (Exception)
         {
             // Console.WriteLine($"ERROR on queue: {tenantLogsQueue.Count}");
         }
     }
     IsTenantLoggingWorking = false;
 }