Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions search/src/main/java/org/zstack/query/QueryFacadeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private Method getReplySetter(AutoQuery at) {
}
}

private void handle(APIQueryMessage msg) {
private APIQueryReply doQuery(APIQueryMessage msg) {
AutoQuery at = autoQueryMap.get(msg.getClass());
if (at == null) {
at = msg.getClass().getAnnotation(AutoQuery.class);
Expand All @@ -374,14 +374,47 @@ private void handle(APIQueryMessage msg) {
if (result.inventories != null) {
replySetter.invoke(reply, result.inventories);
}
bus.reply(msg, reply);
return reply;
} catch (OperationFailureException of) {
throw of;
} catch (Exception e) {
throw new OperationFailureException(inerr("failed to query: %s", e.getMessage()));
}
}

private void handle(APIQueryMessage msg) {
thdf.syncSubmit(new SyncTask<Void>() {
@Override
public Void call() {
APIQueryReply reply;
try {
reply = doQuery(msg);
} catch (OperationFailureException of) {
reply = new APIQueryReply();
reply.setError(of.getErrorCode());
}

bus.reply(msg, reply);
return null;
}

@Override
public String getName() {
return getSyncSignature();
}

@Override
public String getSyncSignature() {
return "api-query";
}

@Override
public int getSyncLevel() {
return getQuerySyncLevel();
}
});
}

private String toZQLConditionString(QueryCondition c) {
// make every condition value as string, the ZQL
// will put them in right type because it knows every field's type
Expand Down