/[storm]/storm/org/nongnu/storm/impl/p2p/P2PPool.java
ViewVC logotype

Diff of /storm/org/nongnu/storm/impl/p2p/P2PPool.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by hemppah, Wed May 7 08:10:31 2003 UTC revision 1.7 by hemppah, Wed May 7 08:21:57 2003 UTC
# Line 58  public class P2PPool extends AbstractLoc Line 58  public class P2PPool extends AbstractLoc
58    
59      public Block get(BlockId id) throws IOException {      public Block get(BlockId id) throws IOException {
60          try {          try {
61              return cache.get(id);              p("Trying to find the block from the local pool...");
62              p("Block found from the local pool..."              return cache.get(id);          
63          } catch(FileNotFoundException _) {          } catch(FileNotFoundException _) {
64              p("Block did't found from the local pool..."              p("Block didn't found from the local pool...");
65              Collector c = map.get(id.toString());              Collector c = map.get(id.toString());
66              for(Iterator i=c.blockingIterator(); i.hasNext();) {              for(Iterator i=c.blockingIterator(); i.hasNext();) {
67                  String url = (String)i.next();                  String url = (String)i.next();
68                  try {                  try {
69                        p("Trying to connect to: " + url);
70                      URLConnection conn = new URL(url).openConnection();                      URLConnection conn = new URL(url).openConnection();
71                      String contentType = conn.getContentType();                      String contentType = conn.getContentType();            
                     p("Trying to connect to: " + url  
72                      if(contentType == null) continue;                      if(contentType == null) continue;
73                      BlockOutputStream bos =                      BlockOutputStream bos =
74                          cache.getBlockOutputStream(conn.getContentType());                          cache.getBlockOutputStream(conn.getContentType());
75                      CopyUtil.copy(conn.getInputStream(), bos);                      CopyUtil.copy(conn.getInputStream(), bos);
76                      if(bos.getBlockId().equals(id))                      if(bos.getBlockId().equals(id)) {
77                                                    p("Block found @ " + url);
78                          return bos.getBlock();                          return bos.getBlock();
79                      else                      } else {
80                          p("Block ids didn't match: "+id+" / "+                          p("Block ids didn't match: "+id+" / "+
81                            bos.getBlockId()+" (from "+url+").");                          bos.getBlockId()+" (from "+url+").");
82                        }
83                  } catch(IOException e) {                  } catch(IOException e) {
84                      // next iteration                      // next iteration
85                  }                  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26