catch IndexControlRWIs_p error if RWI not connected

pull/1/head
reger 11 years ago
parent 38864ae004
commit 3963bca3b6

@ -61,6 +61,7 @@ import net.yacy.peers.Seed;
import net.yacy.repository.Blacklist; import net.yacy.repository.Blacklist;
import net.yacy.repository.Blacklist.BlacklistType; import net.yacy.repository.Blacklist.BlacklistType;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.index.Segment; import net.yacy.search.index.Segment;
import net.yacy.search.query.QueryGoal; import net.yacy.search.query.QueryGoal;
import net.yacy.search.query.QueryModifier; import net.yacy.search.query.QueryModifier;
@ -331,34 +332,38 @@ public class IndexControlRWIs_p {
} }
} }
// generate list // generate list (if RWI connected, otherwise NPE)
if ( post.containsKey("keyhashsimilar") ) { if (sb.getConfigBool(SwitchboardConstants.CORE_SERVICE_RWI, true)) {
try { if ( post.containsKey("keyhashsimilar") ) {
final Iterator<ReferenceContainer<WordReference>> containerIt = try {
segment.termIndex().referenceContainer(keyhash, true, false, 256, false).iterator(); final Iterator<ReferenceContainer<WordReference>> containerIt =
ReferenceContainer<WordReference> container; segment.termIndex().referenceContainer(keyhash, true, false, 256, false).iterator();
ReferenceContainer<WordReference> container;
int i = 0, rows = 0, cols = 0;
prop.put("keyhashsimilar", "1"); int i = 0, rows = 0, cols = 0;
while ( containerIt.hasNext() && i < 256 ) { prop.put("keyhashsimilar", "1");
container = containerIt.next(); while ( containerIt.hasNext() && i < 256 ) {
prop.put( container = containerIt.next();
"keyhashsimilar_rows_" + rows + "_cols_" + cols + "_wordHash", prop.put(
container.getTermHash()); "keyhashsimilar_rows_" + rows + "_cols_" + cols + "_wordHash",
cols++; container.getTermHash());
if ( cols == 8 ) { cols++;
prop.put("keyhashsimilar_rows_" + rows + "_cols", cols); if ( cols == 8 ) {
cols = 0; prop.put("keyhashsimilar_rows_" + rows + "_cols", cols);
rows++; cols = 0;
rows++;
}
i++;
} }
i++; prop.put("keyhashsimilar_rows_" + rows + "_cols", cols);
prop.put("keyhashsimilar_rows", rows + 1);
prop.put("result", "");
} catch (final IOException e ) {
ConcurrentLog.logException(e);
} }
prop.put("keyhashsimilar_rows_" + rows + "_cols", cols);
prop.put("keyhashsimilar_rows", rows + 1);
prop.put("result", "");
} catch (final IOException e ) {
ConcurrentLog.logException(e);
} }
} else {
prop.put("result", "RWI index not connected (see Index Sources & Targets -> <a href='IndexFederated_p.html'>Peer-to-Peer Operation</a>)");
} }
if ( post.containsKey("blacklist") ) { if ( post.containsKey("blacklist") ) {

Loading…
Cancel
Save