Changeset 4718

Show
Ignore:
Timestamp:
06/16/08 15:13:58 (5 months ago)
Author:
xmlhacker
Message:

so that definitely wasn't the right algorithm ;-)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/nuxleus/Source/Nuxleus.Extension.Aws/Agent.cs

    r4715 r4718  
    4545 
    4646            scope.Begin = () => { 
     47                 
    4748                using (WorkerQueue q = new WorkerQueue(m_workers)) { 
    48                     for (int i = 0; i < m_workers; i++) { 
    49                         List<string> lines = new List<string>(); 
    50                         using (StreamReader csvReader = new StreamReader("AD.txt", Encoding.UTF8, true)) { 
    51                             string inputLine; 
    52                             while ((inputLine = csvReader.ReadLine()) != null) { 
    53                                 lines.Add(inputLine); 
    54                             } 
    55                             int runningTotal = 0; 
    56                             List<string> operation = new List<string>(); 
    57                             for (int l = 0; l < lines.Count; l++) { 
    58                                 int length = lines[l].Length; 
    59                                 string thisLine = lines[l]; 
    60  
    61                                 if (runningTotal >= 100) { 
    62                                     runningTotal = 0; 
    63                                     q.EnqueueTask(InvokeOperation<T>(operation)); 
    64                                     operation = new List<string>(); 
    65                                 } 
    66                                 operation.Add(thisLine); 
    67                                 runningTotal += length; 
    68                             } 
    69  
     49                    List<string> lines = new List<string>(); 
     50                    using (StreamReader csvReader = new StreamReader("AD.txt", Encoding.UTF8, true)) { 
     51                        string inputLine; 
     52                        while ((inputLine = csvReader.ReadLine()) != null) { 
     53                            lines.Add(inputLine); 
    7054                        } 
    7155                    } 
     56                    System.Console.WriteLine("Total Tasks: {0}", lines.Count); 
     57                    int loadBalance = (lines.Count / m_workers); 
     58                    System.Console.WriteLine("LoadBalance: {0}", loadBalance); 
     59                    int totalQueues = 0; 
     60                    int totalTasksEnqueued = 0; 
     61                    List<string> operation = new List<string>(); 
     62                    for (int l = 0; l < lines.Count; l++) { 
     63                        string thisLine = lines[l]; 
     64                        operation.Add(thisLine); 
     65                        if (operation.Count >= loadBalance) { 
     66                            System.Console.WriteLine("Operation Length: {0}", operation.Count); 
     67                            q.EnqueueTask(InvokeOperation<T>(operation)); 
     68                            totalTasksEnqueued += operation.Count; 
     69                            operation = new List<string>(); 
     70                            totalQueues += 1; 
     71                        } 
     72                    } 
     73 
     74                    if (operation.Count > 0) { 
     75                        totalTasksEnqueued += operation.Count; 
     76                        totalQueues += 1; 
     77                        q.EnqueueTask(InvokeOperation<T>(operation)); 
     78                    } 
     79 
     80                    System.Console.WriteLine("Total Tasks Enqueued: {0}, Total Queues: {1}", totalTasksEnqueued, totalQueues); 
    7281                } 
    7382            }; 
    74  
    7583        } 
    7684 
     
    107115            System.Console.WriteLine(System.String.Format("Array Length: {0}", inputArray.Length)); 
    108116 
    109             KeyValuePair<string, string>[] geoNames = new KeyValuePair<System.String, System.String>[] {  
    110                             new KeyValuePair<string,string>("geonamesid",(string)inputArray.GetValue(0)), 
    111                             new KeyValuePair<string,string>("names",(string)inputArray.GetValue(1)), 
    112                             new KeyValuePair<string,string>("alternatenames",(string)inputArray.GetValue(3)),  
    113                             new KeyValuePair<string,string>("latitude", (string)inputArray.GetValue(4)), 
    114                             new KeyValuePair<string,string>("longitude", (string)inputArray.GetValue(5)), 
    115                             new KeyValuePair<string,string>("feature_class", (string)inputArray.GetValue(6)), 
    116                             new KeyValuePair<string,string>("feature_code",(string)inputArray.GetValue(7)), 
    117                             new KeyValuePair<string,string>("country_code",(string)inputArray.GetValue(8)), 
    118                             new KeyValuePair<string,string>("cc2",(string)inputArray.GetValue(9)), 
    119                             new KeyValuePair<string,string>("admin1_code",(string)inputArray.GetValue(10)), 
    120                             new KeyValuePair<string,string>("admin2_code",(string)inputArray.GetValue(11)), 
    121                             new KeyValuePair<string,string>("admin3_code",(string)inputArray.GetValue(12)), 
    122                             new KeyValuePair<string,string>("admin4_code",(string)inputArray.GetValue(13)), 
    123                             new KeyValuePair<string,string>("population",(string)inputArray.GetValue(14)), 
    124                             new KeyValuePair<string,string>("elevation",(string)inputArray.GetValue(15)), 
    125                             new KeyValuePair<string,string>("gtopo30",(string)inputArray.GetValue(16)), 
    126                             new KeyValuePair<string,string>("timezone",(string)inputArray.GetValue(17)), 
    127                             new KeyValuePair<string,string>("modification_date",(string)inputArray.GetValue(18)), 
    128                         }; 
    129  
     117            KeyValuePair<string, string>[] geoNames =  
     118                new KeyValuePair<System.String, System.String>[] {  
     119                    new KeyValuePair<string,string>("geonamesid",(string)inputArray.GetValue(0)), 
     120                    new KeyValuePair<string,string>("names",(string)inputArray.GetValue(1)), 
     121                    new KeyValuePair<string,string>("alternatenames",(string)inputArray.GetValue(3)),  
     122                    new KeyValuePair<string,string>("latitude", (string)inputArray.GetValue(4)), 
     123                    new KeyValuePair<string,string>("longitude", (string)inputArray.GetValue(5)), 
     124                    new KeyValuePair<string,string>("feature_class", (string)inputArray.GetValue(6)), 
     125                    new KeyValuePair<string,string>("feature_code",(string)inputArray.GetValue(7)), 
     126                    new KeyValuePair<string,string>("country_code",(string)inputArray.GetValue(8)), 
     127                    new KeyValuePair<string,string>("cc2",(string)inputArray.GetValue(9)), 
     128                    new KeyValuePair<string,string>("admin1_code",(string)inputArray.GetValue(10)), 
     129                    new KeyValuePair<string,string>("admin2_code",(string)inputArray.GetValue(11)), 
     130                    new KeyValuePair<string,string>("admin3_code",(string)inputArray.GetValue(12)), 
     131                    new KeyValuePair<string,string>("admin4_code",(string)inputArray.GetValue(13)), 
     132                    new KeyValuePair<string,string>("population",(string)inputArray.GetValue(14)), 
     133                    new KeyValuePair<string,string>("elevation",(string)inputArray.GetValue(15)), 
     134                    new KeyValuePair<string,string>("gtopo30",(string)inputArray.GetValue(16)), 
     135                    new KeyValuePair<string,string>("timezone",(string)inputArray.GetValue(17)), 
     136                    new KeyValuePair<string,string>("modification_date",(string)inputArray.GetValue(18)), 
     137                }; 
    130138 
    131139            IEnumerator attributeArray = geoNames.GetEnumerator(); 
  • trunk/nuxleus/Source/Nuxleus.Extension.Aws/SimpleDB/Task/PutAttributes.cs

    r4715 r4718  
    6767        public IEnumerable<IAsync> Invoke<T>(Dictionary<XElement, T> responseList) { 
    6868 
    69  
    7069            XNamespace s = "http://schemas.xmlsoap.org/soap/envelope/"; 
    7170 
    72             XElement awsSOAPMessage =  
    73                 new XElement(s + "Envelope", 
    74                     new XElement(s + "Body", 
    75                         SdbAction.PutAttributes(DomainName, ItemName, AttributeArray) 
    76                     ) 
    77                 ); 
     71            XElement awsSOAPMessage = GetRequest(); 
    7872 
    79             foreach (Nuxleus.Extension.AWS.SimpleDB.Model.Attribute attribute in AttributeArray) { 
    80                 System.Console.WriteLine("Name: {0}, Value: {1}, Replace: {2}", attribute.Name, attribute.Value, attribute.Replace); 
    81             } 
     73            return CallWebService<T>(awsSOAPMessage, responseList); 
     74        } 
    8275 
     76        private IEnumerable<IAsync> CallWebService<T>(XElement awsSOAPMessage, Dictionary<XElement, T> responseList) { 
    8377            string rType = LabelAttribute.FromMember(RequestType); 
    8478 
     
    116110 
    117111            using (Stream newStream = request.GetRequestStream()) { 
    118  
    119112                newStream.Write(buffer, 0, contentLength); 
    120113                Async<WebResponse> response = request.GetResponseAsync(); 
     
    127120            } 
    128121        } 
    129  
    130122        private XElement[] CreateAttributeElements() { 
    131123            XElement[] xElements = new XElement[m_attributeArray.Count];