public QueryResults search(String resourceName, String query, Object[] args) {
final Counter finished = new Counter(1);
final DHTQueryResults results = new DHTQueryResults(hitTextPattern);
try {
final OverlayNetwork network = PastryNetwork.getInstance();
if (null == query) {
return null;
} else {
String[] keywords = this.parseQuery(query);
if (keywords.length == 0) {
return null;
}
network.send(keywords[0], new KeywordQueryMessage(keywords, 0, null), new MessageCallback() {
public void onResponse(ResponseMessage response) {
if (response instanceof KeywordQueryRespMessage) {
ScoreDocList sdList = ((KeywordQueryRespMessage) response)
.getSdList();
sdList.sortList();
final Counter counter = new Counter(sdList.size());
for (Iterator itr = sdList.getSdList().iterator(); itr.hasNext(); ) {
ScoreDoc sd = (ScoreDoc) itr.next();
String nodeId = sd.getNodeId();
Integer docId = new Integer(sd.getDocId());
try {
network.sendDirect(nodeId,
new ResourceRequestMessage(docId),
new MessageCallback() {
public void onResponse(
ResponseMessage response) {