public FullConfig(int threads, int records, ErrorRateConfig errorRate, List <FieldAttributes> fields)
 {
     this.threads_count = threads;
     this.records_count = records;
     this.error_rate    = errorRate;
     this.fields        = fields;
 }
Beispiel #2
0
        public static IRecordGenerator ApplyError(IRecordGenerator gen, ErrorRateConfig config)
        {
            IRecordGenerator gen1 = ApplyErrorHelper(config.badValue, "Bad value", gen);
            IRecordGenerator gen2 = ApplyErrorHelper(config.missingField, "Missing field", gen1);
            IRecordGenerator gen3 = ApplyErrorHelper(config.additionalField, "Additional field", gen2);

            return(gen3);
        }
Beispiel #3
0
        public static FullConfig?ParseConfig(JObject jConfig)
        {
            List <FieldAttributes> fields = new List <FieldAttributes>();

            foreach (JObject fieldConfig in (JArray)jConfig["dimension_attributes"])
            {
                string typeID = (string)fieldConfig["type"];
                fields.Add(configToFieldsTranslator.CaseAt(typeID, fieldConfig));
            }

            // TESTING:
            try
            {
                int             threads_count = (int)jConfig["threads_count"];
                int             records_count = (int)jConfig["records_count"] < 2147483647 ? (int)jConfig["records_count"] : 2147483647;
                ErrorRateConfig error_rate    = new ErrorRateConfig
                {
                    missingField    = (double)jConfig["error_rate"]["missing_field"],
                    badValue        = (double)jConfig["error_rate"]["bad_value"],
                    additionalField = (double)jConfig["error_rate"]["additional_field"]
                };

                FullConfig fullConfig = new FullConfig(
                    threads_count,
                    records_count,
                    error_rate,
                    fields
                    );
                return(fullConfig);
            }
            catch (Exception e)
            {
                //Console.WriteLine("Type casting error in thread or record or error_rate.");
                return(null);
            }
        }
Beispiel #4
0
 public Producer(int amount, List <FieldAttributes> fields, ErrorRateConfig errorRate)
 {
     this.Amount          = amount;
     this.recordGenerator = Util.ApplyError(new RecordGenerator(fields), errorRate);
 }