public void ParseIndexRecordIntoDict_EmptySourceDictionary_Return1TeamData() { //ARRANGE sut = new IndexRecordParser(); Dictionary <string, TeamData> result = new Dictionary <string, TeamData>(); //stm_uiiviewer_flume:tomcatlog_index-2017-07-08_1 1 1 23048 0 36.8mb 18.4mb CatIndicesRecord arg = new CatIndicesRecord { Index = "stm_uiiviewer_flume:tomcatlog_index-2017-07-08_1", DocsCount = "23048", StoreSize = "3688800", PrimaryStoreSize = "1844400", TotalMemory = "3688800" }; var expectedTeamData = new TeamData { teamName = "stm", numberOfDocs = "23048", primaryStoreSize = "1844400", totalStoreSize = "3688800" }; expectedTeamDataDict.Add("stm", expectedTeamData); //ACT result = sut.ParseIndexRecordIntoDict(result, arg); //ASSERT AreSameDictionaries(expectedTeamDataDict, result); }
internal Index(CatIndicesRecord index) { this.DocsCount = index.DocsCount.ParseLong(); this.DocsDeleted = index.DocsDeleted.ParseLong(); this.Health = index.Health; this.Name = index.Index; this.Primary = index.Primary; this.PrimaryStoreSize = index.PrimaryStoreSize; this.Replica = index.Replica; this.Status = index.Status; this.StoreSize = index.StoreSize; this.TotalMemory = index.TotalMemory; }
public void ParseIndexRecordIntoDict_NonEmptySourceDictionary_Return2TeamData() { //ARRANGE sut = new IndexRecordParser(); Dictionary <string, TeamData> result = new Dictionary <string, TeamData>(); var preexisitngTeamData = new TeamData { teamName = "team1", numberOfDocs = "123", primaryStoreSize = "213123", totalStoreSize = "426000" }; result.Add("team1", preexisitngTeamData); //ngenp2ac_masapps_applogs_index-2017-06-17_1 1 1 336 0 1mb 550.6kb CatIndicesRecord arg = new CatIndicesRecord { Index = "ngenp2ac_masapps_applogs_index-2017-06-17_1 ", DocsCount = "336", StoreSize = "3688800", PrimaryStoreSize = "1844400", TotalMemory = "500000", }; var expectedTeamData = new TeamData { teamName = "ngenp2ac", numberOfDocs = "336", primaryStoreSize = "1844400", totalStoreSize = "500000" }; expectedTeamDataDict.Add("team1", preexisitngTeamData); expectedTeamDataDict.Add("ngenp2ac", expectedTeamData); //ACT result = sut.ParseIndexRecordIntoDict(result, arg); //ASSERT AreSameDictionaries(expectedTeamDataDict, result); }
public void ParseIndexRecordIntoDict_DuplicateTeamInDictionary_Return1UpdatedTeamData() { //ARRANGE sut = new IndexRecordParser(); Dictionary <string, TeamData> result = new Dictionary <string, TeamData>(); //wcm_publisher_tridion_index-2017-07-10_1 1 1 4999 0 5.7mb 3.8mb var preexisitngTeamData = new TeamData { teamName = "wcm", numberOfDocs = "4999", primaryStoreSize = "380000", totalStoreSize = "570000" }; result.Add("wcm", preexisitngTeamData); CatIndicesRecord arg = new CatIndicesRecord { Index = "wcm_some_other_index-2017-07-10_1", DocsCount = "1000", PrimaryStoreSize = "20000", TotalMemory = "40000", }; var expectedUpdatedTeamData = new TeamData { teamName = "wcm", numberOfDocs = "5999", primaryStoreSize = "400000", totalStoreSize = "610000" }; expectedTeamDataDict.Add("wcm", expectedUpdatedTeamData); //ACT result = sut.ParseIndexRecordIntoDict(result, arg); //ASSERT AreSameDictionaries(expectedTeamDataDict, result); }
//Parses a new Index into our Dictionary by either adding a new K,V pair or updating an already existing pair. Returns our dictionary back public Dictionary <string, TeamData> ParseIndexRecordIntoDict(Dictionary <string, TeamData> teamDataDict, CatIndicesRecord record) { //Get the official team name from the index name string indexTeamName = teamNameParser.GetTeamName(record.Index); //If this team is not already in our dictionary, instantiate a new TeamData and add the pair in if (!teamDataDict.ContainsKey(indexTeamName)) { TeamData teamData = new TeamData { teamName = indexTeamName, primaryStoreSize = record.PrimaryStoreSize, numberOfDocs = record.DocsCount, totalStoreSize = record.TotalMemory }; teamDataDict.Add(indexTeamName, teamData); } //Otherwise, we have to update the TeamData value for this team's additional index in ES else { TeamData previousTeamData = teamDataDict[indexTeamName]; TeamData updatedTeamData = new TeamData { teamName = previousTeamData.teamName, primaryStoreSize = "" + (Convert.ToInt64(previousTeamData.primaryStoreSize) + Convert.ToInt64(record.PrimaryStoreSize)), numberOfDocs = "" + (Convert.ToInt64(previousTeamData.numberOfDocs) + Convert.ToInt64(record.DocsCount)), totalStoreSize = "" + (Convert.ToInt64(previousTeamData.totalStoreSize) + Convert.ToInt64(record.TotalMemory)) }; teamDataDict[indexTeamName] = updatedTeamData; } return(teamDataDict); }
public bool DeleteIndex(CatIndicesRecord index) { IDeleteIndexResponse response = client.DeleteIndex(index.Index); return(response.Acknowledged); }