use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class MetadataNode method addFeedPolicy.
@Override
public void addFeedPolicy(JobId jobId, FeedPolicyEntity feedPolicy) throws MetadataException, RemoteException {
try {
// Insert into the 'FeedPolicy' dataset.
FeedPolicyTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getFeedPolicyTupleTranslator(true);
ITupleReference feedPolicyTuple = tupleReaderWriter.getTupleFromMetadataEntity(feedPolicy);
insertTupleIntoIndex(jobId, MetadataPrimaryIndexes.FEED_POLICY_DATASET, feedPolicyTuple);
} catch (HyracksDataException e) {
if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.DUPLICATE_KEY) {
throw new MetadataException("A feed policy with this name " + feedPolicy.getPolicyName() + " already exists in dataverse '" + feedPolicy.getPolicyName() + "'.", e);
} else {
throw new MetadataException(e);
}
} catch (ACIDException e) {
throw new MetadataException(e);
}
}
use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class MetadataNode method deleteEntity.
/**
* Delete entity from index
*
* @param jobId
* @param entity
* @param tupleTranslator
* @param index
* @throws MetadataException
*/
private <T> void deleteEntity(JobId jobId, T entity, IMetadataEntityTupleTranslator<T> tupleTranslator, IMetadataIndex index) throws MetadataException {
try {
ITupleReference tuple = tupleTranslator.getTupleFromMetadataEntity(entity);
deleteTupleFromIndex(jobId, index, tuple);
} catch (HyracksDataException | ACIDException e) {
throw new MetadataException(e);
}
}
use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class MetadataNode method dropLibrary.
@Override
public void dropLibrary(JobId jobId, String dataverseName, String libraryName) throws MetadataException, RemoteException {
Library library = getLibrary(jobId, dataverseName, libraryName);
if (library == null) {
throw new MetadataException("Cannot drop library '" + library + "' because it doesn't exist.");
}
try {
// Delete entry from the 'Library' dataset.
ITupleReference searchKey = createTuple(dataverseName, libraryName);
// Searches the index for the tuple to be deleted. Acquires an S
// lock on the 'Adapter' dataset.
ITupleReference datasetTuple = getTupleToBeDeleted(jobId, MetadataPrimaryIndexes.LIBRARY_DATASET, searchKey);
deleteTupleFromIndex(jobId, MetadataPrimaryIndexes.LIBRARY_DATASET, datasetTuple);
// TODO: Change this to be a BTree specific exception, e.g.,
// BTreeKeyDoesNotExistException.
} catch (HyracksDataException e) {
if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.UPDATE_OR_DELETE_NON_EXISTENT_KEY) {
throw new MetadataException("Cannot drop library '" + libraryName, e);
} else {
throw new MetadataException(e);
}
} catch (ACIDException e) {
throw new MetadataException(e);
}
}
use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class LogBuffer method notifyFlushTermination.
public void notifyFlushTermination() throws ACIDException {
LogRecord logRecord = null;
try {
logRecord = (LogRecord) flushQ.take();
} catch (InterruptedException e) {
//ignore
}
synchronized (logRecord) {
logRecord.isFlushed(true);
logRecord.notifyAll();
}
PrimaryIndexOperationTracker opTracker = logRecord.getOpTracker();
if (opTracker != null) {
try {
opTracker.triggerScheduleFlush(logRecord);
} catch (HyracksDataException e) {
throw new ACIDException(e);
}
}
}
use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class LogReader method refillLogReadBuffer.
/**
* Continues log analysis between log file splits.
*
* @return true if log continues, false if EOF
* @throws ACIDException
*/
private boolean refillLogReadBuffer() throws ACIDException {
try {
if (readLSN % logFileSize == logFile.size()) {
logFile.close();
readLSN += logFileSize - (readLSN % logFileSize);
getLogFile();
}
return fillLogReadBuffer();
} catch (IOException e) {
throw new ACIDException(e);
}
}
Aggregations