this.queueMap = new HashMap<String, IBigQueue>();
}
@Override
public QueueResponse enqueue(String topic, QueueRequest req) throws TException {
QueueResponse resp = new QueueResponse();
if (topic == null) {
resp.setResultCode(ResultCode.FAILURE);
return resp;
}
IBigQueue bigQueue = queueMap.get(topic);
if (bigQueue == null) {
synchronized(lock) {
bigQueue = queueMap.get(topic);
if (bigQueue == null) {
try {
bigQueue = new BigQueueImpl(queueDir, topic);
queueMap.put(topic, bigQueue);
} catch (IOException e) {
resp.setResultCode(ResultCode.FAILURE);
return resp;
}
}
}
}
if (req.getData() != null && req.getData().length > 0) {
try {
bigQueue.enqueue(req.getData());
} catch (IOException e) {
resp.setResultCode(ResultCode.FAILURE);
return resp;
}
resp.setResultCode(ResultCode.SUCCESS);
return resp;
} else {
resp.setResultCode(ResultCode.FAILURE);
return resp;
}
}