use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class ResultState method read.
public synchronized long read(long offset, ByteBuffer buffer) throws HyracksDataException {
long readSize = 0;
while (offset >= size && !eos.get() && !failed.get()) {
try {
wait();
} catch (InterruptedException e) {
throw new HyracksDataException(e);
}
}
if ((offset >= size && eos.get()) || failed.get()) {
return readSize;
}
if (readFileHandle == null) {
initReadFileHandle();
}
readSize = ioManager.syncRead(readFileHandle, offset, buffer);
return readSize;
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class ResultState method read.
public long read(DatasetMemoryManager datasetMemoryManager, long offset, ByteBuffer buffer) throws HyracksDataException {
long readSize = 0;
synchronized (this) {
while (offset >= size && !eos.get() && !failed.get()) {
try {
wait();
} catch (InterruptedException e) {
throw new HyracksDataException(e);
}
}
if ((offset >= size && eos.get()) || failed.get()) {
return readSize;
}
if (offset < persistentSize) {
if (readFileHandle == null) {
initReadFileHandle();
}
readSize = ioManager.syncRead(readFileHandle, offset, buffer);
if (readSize < 0) {
throw new HyracksDataException("Premature end of file");
}
}
if (readSize < buffer.capacity()) {
long localPageOffset = offset - persistentSize;
int localPageIndex = (int) (localPageOffset / DatasetMemoryManager.getPageSize());
int pageOffset = (int) (localPageOffset % DatasetMemoryManager.getPageSize());
Page page = getPage(localPageIndex);
if (page == null) {
return readSize;
}
readSize += buffer.remaining();
buffer.put(page.getBuffer().array(), pageOffset, buffer.remaining());
}
}
datasetMemoryManager.pageReferenced(resultSetPartitionId);
return readSize;
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class ExceptionUtils method setNodeIds.
/**
* Associate a node with a list of exceptions
*
* @param exceptions
* @param nodeId
*/
public static void setNodeIds(Collection<Exception> exceptions, String nodeId) {
List<Exception> newExceptions = new ArrayList<>();
for (Exception e : exceptions) {
if (e instanceof HyracksDataException) {
newExceptions.add(HyracksDataException.create((HyracksDataException) e, nodeId));
} else {
newExceptions.add(new HyracksDataException(ErrorCode.HYRACKS, ErrorCode.FAILURE_ON_NODE, e.getMessage(), e, nodeId));
}
}
exceptions.clear();
exceptions.addAll(newExceptions);
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class DatasetPartitionWriter method registerResultPartitionLocation.
void registerResultPartitionLocation(boolean empty) throws HyracksDataException {
try {
if (!partitionRegistered) {
manager.registerResultPartitionLocation(jobId, resultSetId, partition, nPartitions, orderedResult, empty);
partitionRegistered = true;
}
} catch (HyracksException e) {
if (e instanceof HyracksDataException) {
throw (HyracksDataException) e;
} else {
throw new HyracksDataException(e);
}
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class MiniDFSClusterFactory method getMiniDFSCluster.
public MiniDFSCluster getMiniDFSCluster(Configuration conf, int numberOfNC) throws HyracksDataException {
try {
MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
builder.numDataNodes(numberOfNC);
MiniDFSCluster dfsCluster = builder.build();
return dfsCluster;
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
Aggregations