use of org.apache.asterix.runtime.message.ResourceIdRequestResponseMessage in project asterixdb by apache.
the class GlobalResourceIdFactory method createId.
@Override
public long createId() throws HyracksDataException {
try {
ResourceIdRequestResponseMessage reponse = null;
//if there already exists a response, use it
if (!resourceIdResponseQ.isEmpty()) {
synchronized (resourceIdResponseQ) {
if (!resourceIdResponseQ.isEmpty()) {
reponse = resourceIdResponseQ.take();
}
}
}
//if no response available or it has an exception, request a new one
if (reponse == null || reponse.getException() != null) {
ResourceIdRequestMessage msg = new ResourceIdRequestMessage(nodeId);
((INCMessageBroker) serviceCtx.getMessageBroker()).sendMessageToCC(msg);
reponse = resourceIdResponseQ.take();
if (reponse.getException() != null) {
throw new HyracksDataException(reponse.getException().getMessage());
}
}
return reponse.getResourceId();
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
Aggregations