use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class LogManagerWithReplication method syncAppendToLogTail.
@Override
protected synchronized void syncAppendToLogTail(ILogRecord logRecord) throws ACIDException {
if (logRecord.getLogSource() == LogSource.LOCAL && logRecord.getLogType() != LogType.FLUSH) {
ITransactionContext txnCtx = logRecord.getTxnCtx();
if (txnCtx.getTxnState() == ITransactionManager.ABORTED && logRecord.getLogType() != LogType.ABORT) {
throw new ACIDException("Aborted job(" + txnCtx.getJobId() + ") tried to write non-abort type log record.");
}
}
final int logRecordSize = logRecord.getLogSize();
// Make sure the log will not exceed the log file size
if (getLogFileOffset(appendLSN.get()) + logRecordSize >= logFileSize) {
prepareNextLogFile();
prepareNextPage(logRecordSize);
} else if (!appendPage.hasSpace(logRecordSize)) {
prepareNextPage(logRecordSize);
}
appendPage.append(logRecord, appendLSN.get());
if (logRecord.getLogType() == LogType.FLUSH) {
logRecord.setLSN(appendLSN.get());
}
appendLSN.addAndGet(logRecordSize);
}
use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class LogReader method fillLogReadBuffer.
private boolean fillLogReadBuffer(int readSize, ByteBuffer readBuffer) throws ACIDException {
int size = 0;
int read = 0;
readBuffer.position(0);
readBuffer.limit(readSize);
try {
logFile.position(readLSN % logFileSize);
//Therefore we want to break out only when either the buffer is full, or we reach EOF.
while (size < readSize && read != -1) {
read = logFile.read(readBuffer);
if (read > 0) {
size += read;
}
}
} catch (IOException e) {
throw new ACIDException(e);
}
readBuffer.position(0);
readBuffer.limit(size);
if (size == 0 && read == -1) {
//EOF
return false;
}
bufferBeginLSN = readLSN;
return true;
}
use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class LogReader method getLogFile.
private void getLogFile() throws ACIDException {
try {
logFile = logMgr.getLogFile(readLSN);
fileBeginLSN = logFile.getFileBeginLSN();
} catch (IOException e) {
throw new ACIDException(e);
}
}
use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class CommitRuntime method open.
@Override
public void open() throws HyracksDataException {
try {
transactionContext = transactionManager.getTransactionContext(jobId, false);
transactionContext.setWriteTxn(isWriteTransaction);
ILogMarkerCallback callback = TaskUtil.get(ILogMarkerCallback.KEY_MARKER_CALLBACK, ctx);
logRecord = new LogRecord(callback);
if (isSink) {
return;
}
initAccessAppend(ctx);
writer.open();
} catch (ACIDException e) {
throw new HyracksDataException(e);
}
}
use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.
the class SecondaryIndexModificationOperationCallbackFactory method createModificationOperationCallback.
@Override
public IModificationOperationCallback createModificationOperationCallback(LocalResource resource, IHyracksTaskContext ctx, IOperatorNodePushable operatorNodePushable) throws HyracksDataException {
ITransactionSubsystem txnSubsystem = txnSubsystemProvider.getTransactionSubsystem(ctx);
IResourceLifecycleManager indexLifeCycleManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getDatasetLifecycleManager();
ILSMIndex index = (ILSMIndex) indexLifeCycleManager.get(resource.getPath());
if (index == null) {
throw new HyracksDataException("Index(id:" + resource.getId() + ") is not registered.");
}
try {
ITransactionContext txnCtx = txnSubsystem.getTransactionManager().getTransactionContext(jobId, false);
DatasetLocalResource aResource = (DatasetLocalResource) resource.getResource();
IModificationOperationCallback modCallback = new SecondaryIndexModificationOperationCallback(new DatasetId(datasetId), primaryKeyFields, txnCtx, txnSubsystem.getLockManager(), txnSubsystem, resource.getId(), aResource.getPartition(), resourceType, indexOp);
txnCtx.registerIndexAndCallback(resource.getId(), index, (AbstractOperationCallback) modCallback, false);
return modCallback;
} catch (ACIDException e) {
throw new HyracksDataException(e);
}
}
Aggregations