00001 #ifndef TRANS_CACHE_ENTRY_H 00002 #define TRANS_CACHE_ENTRY_H 00003 00004 //-------------------------------------------------------------------- 00005 // 00006 // This file is part of PEACE. 00007 // 00008 // PEACE is free software: you can redistribute it and/or modify it 00009 // under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation, either version 3 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // PEACE is distributed in the hope that it will be useful, but 00014 // WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with PEACE. If not, see <http://www.gnu.org/licenses/>. 00020 // 00021 // Miami University makes no representations or warranties about the 00022 // suitability of the software, either express or implied, including 00023 // but not limited to the implied warranties of merchantability, 00024 // fitness for a particular purpose, or non-infringement. Miami 00025 // University shall not be liable for any damages suffered by licensee 00026 // as a result of using, result of using, modifying or distributing 00027 // this software or its derivatives. 00028 // 00029 // By using or copying this Software, Licensee agrees to abide by the 00030 // intellectual property laws, and all other applicable laws of the 00031 // U.S., and the terms of GNU General Public License (version 3). 00032 // 00033 // Authors: Dhananjai M. Rao raodm@muohio.edu 00034 // 00035 //--------------------------------------------------------------------- 00036 00037 #include "HashMap.h" 00038 #include "MSTCache.h" 00039 00040 /** \typedef HashMap<int, CachedESTInfo> TransCacheMap 00041 00042 \brief A shortcut to refer to a hash map of CachedESTInfo. 00043 00044 This typedef provides a convenient shortcut to refer to a hash map 00045 containing the information to compute metrics using 00046 conditional-transitivity. The key into this hash map is the index 00047 of the EST to which a CachedESTInfo corresponds to. This index is 00048 the value in CachedESTInfo::estIdx. 00049 */ 00050 typedef HashMap<int, CachedESTInfo> TransCacheMap; 00051 00052 /** Class to encapsulate information needed to apply 00053 conditional-transitivity. 00054 00055 This class has been introduced to provide a convenient intreface 00056 to encapsulate information required to apply 00057 conditional-transitivity between a given pair of ESTs. This class 00058 contains metric information pertaining to a single EST whose index 00059 is identified by the estIdx instance variable in this class. The 00060 metric information is stored as a set of CachedESTInfo objects 00061 that are organized into the following two hash maps: 00062 00063 <ol> 00064 00065 <li>The parentInfo hash map contains CachedESTInfo objects 00066 corresponding to the parent(s) of estIdx. These entries form one 00067 set of relationships necessary to apply conditional-transitivity 00068 with various entries in the peerInfo hash map.</li> 00069 00070 <li>peerInfo hash map contains CachedESTInfo objects corresponding 00071 to other ESTs with which estIdx could \em potentially have 00072 conditional-transivity relationships. However, the applicability 00073 of transitivity is established only when the need arises. </li> 00074 00075 </ol> 00076 00077 The TransCacheEntry is created by the TransMSTClusterMaker after 00078 an EST has been added to the MST. Once an EST has been added to 00079 the MST, the top subset of CachedESTInfo is broadcasted to all the 00080 processes. Each process then creates a set of TransCaceEntry 00081 objects for all the newly added ESTs and updates the list of 00082 related ESTs in parentInfo and peerInfo hash maps in this class. 00083 */ 00084 class TransCacheEntry { 00085 // Friend declaration to enable TransMSTClusterMaker to 00086 // instantiate objects of this type. 00087 friend class TransMSTClusterMaker; 00088 public: 00089 /** Constructor. 00090 00091 The one and only constructor for this class. The constructor 00092 has been made public to enable this class to be used in 00093 conjunction STL data structures. Currently this constructor 00094 is called from the TransMSTClusterMaker::populateCaches() 00095 method. 00096 00097 \param[in] estIdx The index of the EST to which this 00098 TransCacheEntry is associated with. This value is simply 00099 copied into the corresponding instance variable. 00100 */ 00101 TransCacheEntry(const int estIdx = -1); 00102 00103 /** The destructor. 00104 00105 Currently, this class does not use any dynamic memory and all 00106 the memory is automatically managed by the encapsulated 00107 objects. Consequently, the destructor does not have any 00108 specific tasks to perform. 00109 */ 00110 virtual ~TransCacheEntry();// {} 00111 00112 /** Extract and add metric entries in this cache entry. 00113 00114 This method extracts information pertaining to ESTs in the 00115 range startIndex <= otherESTidx < endIndex and the parentInfo 00116 hash map must not have an existing entry for 00117 reference.refESTidx. 00118 00119 \param[in] reference The reference information with respect to 00120 which entries in the metrics list have to be processed. Note 00121 that reference.estIdx must be equal to this.estIdx. 00122 00123 \param[in] metrics The list of metrics from which necessary 00124 entries for this cache must be extracted and stored. Note 00125 that in a distributed scenario, it is not necessary to store 00126 all the metrics because not all comparisons are performed by 00127 all the processes. 00128 00129 \param[in] startIndex The index of the EST starting from which 00130 the owner process is responsible for computing metrics. 00131 00132 \param[in] endIndex The index of the last EST before which the 00133 owner process is responsible for computing metrics. 00134 */ 00135 void addEntries(const CachedESTInfo& reference, const SMList& metrics, 00136 const int UNREFERENCED_PARAMETER(startIndex), 00137 const int UNREFERENCED_PARAMETER(endIndex)); 00138 00139 /** Obtain an existing metric from this cache. 00140 00141 This method may be used to obtain an estimated metric value 00142 between this.estIdx and otherESTidx, assuming a suitable entry 00143 is available in this cache. 00144 00145 \param[in] otherESTidx The index of EST to which an estimated 00146 metric value is expected. If otherESTidx == this.estIdx this 00147 method always returns \c true and sets metric (parameter) to 0 00148 (zero). 00149 00150 \param[out] metric If a valid entry is found in this cache 00151 then this parameter is updated with the estimated value. 00152 Otherwise this parameter is unaltered by this method. 00153 00154 \return This method returns \c true if an estimated entry 00155 could be determined using transitivity. Otherwise this method 00156 returns false. 00157 */ 00158 bool getMetric(const int otherESTidx, float& metric) const; 00159 00160 protected: 00161 /** The index of the EST to which this trans cache entry pertains 00162 to. 00163 00164 This instance variable maintains the index of the EST to which 00165 this trans cache entry pertains to. This value is set after 00166 the object is instantiated and is never changed during the 00167 life time of this object. 00168 */ 00169 int estIdx; 00170 00171 private: 00172 /** The parent metrics related to estIdx EST. 00173 00174 This hash map contains a set of CachedESTInfo that are used to 00175 determine one of the metrics needed for computing metrics 00176 using conditional-transitivity. These are the reference 00177 entries with respect to which entries are mainted in the 00178 peerInfo hash map. Entries in this cache are added by the 00179 addEntries() method in this class. 00180 */ 00181 //TransCacheMap parentInfo; 00182 00183 /** The actual cache of metrics related to estIdx EST. 00184 00185 This hash map contains a set of CachedESTInfo that are used to 00186 compute metrics using conditional-transitivity. Entries in 00187 this cache are added by the addEntries() method in this class. 00188 */ 00189 TransCacheMap* peerInfo; 00190 }; 00191 00192 #endif