| 1 | // $Id: PnfsGetCacheLocationsMessage.java,v 1.5 2007-05-24 13:51:05 tigran Exp $ |
| 2 | |
| 3 | package diskCacheV111.vehicles; |
| 4 | import diskCacheV111.util.* ; |
| 5 | |
| 6 | import java.util.*; |
| 7 | |
| 8 | public class PnfsGetCacheLocationsMessage extends PnfsMessage { |
| 9 | |
| 10 | private List<String> _cacheLocations = null; |
| 11 | |
| 12 | private static final long serialVersionUID = 6603606352524630293L; |
| 13 | |
| 14 | public PnfsGetCacheLocationsMessage(){ |
| 15 | setReplyRequired(true); |
| 16 | } |
| 17 | |
| 18 | public PnfsGetCacheLocationsMessage(PnfsId pnfsId){ |
| 19 | super(pnfsId); |
| 20 | setReplyRequired(true); |
| 21 | } |
| 22 | |
| 23 | public List<String> getCacheLocations(){ |
| 24 | return _cacheLocations; |
| 25 | } |
| 26 | |
| 27 | public void setCacheLocations(List<String> cacheLocations){ |
| 28 | _cacheLocations = cacheLocations; |
| 29 | } |
| 30 | public String toString(){ |
| 31 | StringBuffer sb = new StringBuffer() ; |
| 32 | sb.append(getPnfsId()).append(";locs=") ; |
| 33 | if( _cacheLocations != null ) |
| 34 | for( String location: _cacheLocations ) |
| 35 | sb.append(location). |
| 36 | append(",") ; |
| 37 | return sb.toString() ; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public boolean invalidates(Message message) |
| 42 | { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public boolean fold(Message message) |
| 48 | { |
| 49 | if (message.getClass().equals(PnfsGetCacheLocationsMessage.class)) { |
| 50 | PnfsId pnfsId = getPnfsId(); |
| 51 | String path = getPnfsPath(); |
| 52 | PnfsGetCacheLocationsMessage msg = |
| 53 | (PnfsGetCacheLocationsMessage) message; |
| 54 | if ((pnfsId == null || pnfsId.equals(msg.getPnfsId())) && |
| 55 | (path == null || path.equals(msg.getPnfsPath())) && |
| 56 | (getSubject().equals(msg.getSubject()))) { |
| 57 | setPnfsId(msg.getPnfsId()); |
| 58 | setPnfsPath(msg.getPnfsPath()); |
| 59 | setCacheLocations(msg.getCacheLocations()); |
| 60 | return true; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | return false; |
| 65 | } |
| 66 | } |