use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class PersistentLocalResourceRepository method getIndexFileRef.
public IndexFileProperties getIndexFileRef(String absoluteFilePath) throws HyracksDataException {
//TODO pass relative path
final String[] tokens = absoluteFilePath.split(File.separator);
if (tokens.length < 5) {
throw new HyracksDataException("Invalid file format");
}
String fileName = tokens[tokens.length - 1];
String index = tokens[tokens.length - 2];
String dataverse = tokens[tokens.length - 3];
String partition = tokens[tokens.length - 4];
int partitionId = StoragePathUtil.getPartitionNumFromName(partition);
String relativePath = getLocalResourceRelativePath(absoluteFilePath);
final LocalResource lr = get(relativePath);
int datasetId = lr == null ? -1 : ((DatasetLocalResource) lr.getResource()).getDatasetId();
return new IndexFileProperties(partitionId, dataverse, index, fileName, datasetId);
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class PersistentLocalResourceRepository method createReplicationJob.
private void createReplicationJob(ReplicationOperation operation, FileReference fileRef) throws HyracksDataException {
/**
* Durable resources path format:
* /partition/dataverse/idx/fileName
* Temporary resources path format:
* /partition/TEMP_DATASETS_STORAGE_FOLDER/dataverse/idx/fileName
*/
String[] fileNameTokens = fileRef.getAbsolutePath().split(File.separator);
String partitionDir = fileNameTokens[fileNameTokens.length - 4];
//exclude temporary datasets resources
if (!partitionDir.equals(StoragePathUtil.TEMP_DATASETS_STORAGE_FOLDER)) {
filesToBeReplicated.clear();
filesToBeReplicated.add(fileRef.getAbsolutePath());
ReplicationJob job = new ReplicationJob(ReplicationJobType.METADATA, operation, ReplicationExecutionType.SYNC, filesToBeReplicated);
try {
replicationManager.submitJob(job);
} catch (IOException e) {
throw new HyracksDataException(e);
}
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class NonDeterministicPartitionBatchManager method getNextBatch.
@Override
public synchronized void getNextBatch(List<IFrameReader> batch, int size) throws HyracksDataException {
if (partitions.size() <= size) {
batch.addAll(partitions);
partitions.clear();
} else if (partitions.size() > size) {
List<IFrameReader> sublist = partitions.subList(0, size);
batch.addAll(sublist);
sublist.clear();
}
if (batch.size() == size) {
return;
}
this.batch = batch;
this.requiredSize = size;
while (batch.size() < size) {
try {
wait();
} catch (InterruptedException e) {
throw new HyracksDataException(e);
}
}
this.batch = null;
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class InputChannelFrameReader method nextFrame.
/**
* This implementation works under the truth that one Channel is neverNonDeterministicChannelReader shared by two readers.
* More precisely, one channel only has exact one reader and one writer side.
*
* @param frame
* outputFrame
* @return {@code true} if succeed to read the data from the channel to the {@code frame}.
* Otherwise return {@code false} if the end of stream is reached.
* @throws HyracksDataException
*/
@Override
public boolean nextFrame(IFrame frame) throws HyracksDataException {
if (!canGetNextBuffer()) {
return false;
}
frame.reset();
ByteBuffer srcFrame = channel.getNextBuffer();
int nBlocks = FrameHelper.deserializeNumOfMinFrame(srcFrame);
frame.ensureFrameSize(frame.getMinSize() * nBlocks);
FrameUtils.copyWholeFrame(srcFrame, frame.getBuffer());
channel.recycleBuffer(srcFrame);
for (int i = 1; i < nBlocks; ++i) {
if (!canGetNextBuffer()) {
throw new HyracksDataException("InputChannelReader is waiting for the new frames, but the input stream is finished");
}
srcFrame = channel.getNextBuffer();
frame.getBuffer().put(srcFrame);
channel.recycleBuffer(srcFrame);
}
if (frame.getBuffer().hasRemaining()) {
// bigger frame
FrameHelper.clearRemainingFrame(frame.getBuffer(), frame.getBuffer().position());
}
frame.getBuffer().flip();
return true;
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class IntArraySerializerDeserializer method deserialize.
@Override
public int[] deserialize(DataInput in) throws HyracksDataException {
try {
int len = in.readInt();
int[] array = new int[len];
for (int i = 0; i < array.length; ++i) {
array[i] = in.readInt();
}
return array;
} catch (IOException e) {
throw new HyracksDataException(e);
}
}
Aggregations