Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.RecordException


    }

    @Override
    public Record cloneRecord(IdentityRecordStack parentRecords) throws RecordException {
        if (parentRecords.contains(this)) {
            throw new RecordException("A record may not be nested in itself: " + id);
        }

        RecordImpl record = new RecordImpl();
        record.id = id;
        record.version = version;
View Full Code Here


    private Object tryCloneValue(final IdentityRecordStack parentRecords, final Entry<QName, Object> entry) throws RecordException {
        try {
            return cloneValue(entry.getValue(), parentRecords);
        } catch (CloneNotSupportedException e) {
            throw new RecordException("Failed to clone record", e);
        }
    }
View Full Code Here

        QName recordTypeName = getRecordTypeName();
        if (recordTypeName != null) {
            return new QName(recordTypeName.getNamespace(), name);
        }

        throw new RecordException("Namespace could not be resolved for name '" + name +
            "' since no default namespace was given and no record type is set.");
    }
View Full Code Here

        if (record.getId() == null) {
            // While we could generate an ID ourselves in this case, this would defeat partly the purpose of
            // createOrUpdate, which is that clients would be able to retry the operation (in case of IO exceptions)
            // without having to worry that more than one record might be created.
            throw new RecordException("Record ID is mandatory when using create-or-update.");
        }

        byte[] rowId = record.getId().toBytes();
        Get get = new Get(rowId);
        get.addColumn(RecordCf.DATA.bytes, RecordColumn.DELETED.bytes);

        int attempts;

        for (attempts = 0; attempts < 3; attempts++) {
            Result result;
            try {
                result = recordTable.get(get);
            } catch (IOException e) {
                throw new RecordException("Error reading record row for record id " + record.getId(), e);
            }

            byte[] deleted = recdec.getLatest(result, RecordCf.DATA.bytes, RecordColumn.DELETED.bytes);
            if ((deleted == null) || (Bytes.toBoolean(deleted))) {
                // do the create
                try {
                    return create(record);
                } catch (RecordExistsException e) {
                    // someone created the record since we checked, we will try again
                }
            } else {
                // do the update
                try {
                    record = update(record, false, useLatestRecordType);
                    return record;
                } catch (RecordNotFoundException e) {
                    // some deleted the record since we checked, we will try again
                }
            }
        }

        throw new RecordException("Create-or-update failed after " + attempts +
                " attempts, toggling between create and update mode.");
    }
View Full Code Here

                newRecord.setResponseStatus(ResponseStatus.CREATED);
                removeUnidirectionalState(newRecord);
                return newRecord;

            } catch (IOException e) {
                throw new RecordException("Exception occurred while creating record '" + recordId + "' in HBase table",
                        e);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                throw new RecordException("Exception occurred while creating record '" + recordId + "' in HBase table",
                        e);
            } catch (BlobException e) {
                throw new RecordException("Exception occurred while creating record '" + recordId + "'",
                        e);
            }
        } finally {
            metrics.report(Action.CREATE, System.currentTimeMillis() - before);
        }
View Full Code Here

            // Check if the update is an update of mutable fields
            if (updateVersion) {
                try {
                    return updateMutableFields(record, useLatestRecordType, conditions, fieldTypes);
                } catch (BlobException e) {
                    throw new RecordException("Exception occurred while updating record '" + record.getId() + "'",
                            e);
                }
            } else {
                return updateRecord(record, useLatestRecordType, conditions, fieldTypes);
            }
View Full Code Here

            removeUnidirectionalState(newRecord);
            return newRecord;

        } catch (IOException e) {
            throw new RecordException("Exception occurred while updating record '" + recordId + "' on HBase table",
                    e);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RecordException("Exception occurred while updating record '" + recordId + "' on HBase table",
                    e);
        } catch (BlobException e) {
            throw new RecordException("Exception occurred while putting updated record '" + recordId
                    + "' on HBase table", e);
        }
    }
View Full Code Here

                newRecord.setResponseStatus(ResponseStatus.UP_TO_DATE);
            }

            setRecordTypesAfterUpdate(record, originalRecord, changedScopes);
        } catch (IOException e) {
            throw new RecordException("Exception occurred while updating record '" + recordId + "' on HBase table",
                    e);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RecordException("Exception occurred while updating record '" + recordId + "' on HBase table",
                    e);
        }

        removeUnidirectionalState(newRecord);
        return newRecord;
View Full Code Here

            // Clear the old data and delete any referenced blobs
            clearData(recordId, originalRecord, originalRecord.getVersion());

        } catch (IOException e) {
            throw new RecordException("Exception occurred while deleting record '" + recordId + "' on HBase table", e);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RecordException("Exception occurred while deleting record '" + recordId + "' on HBase table", e);
        } finally {
            long after = System.currentTimeMillis();
            metrics.report(Action.DELETE, (after - before));
        }
View Full Code Here

            writeQName(entry.getKey(), output);
            output.writeUTF(valueType.getName());
            try {
                valueType.write(entry.getValue(), output, new IdentityRecordStack());
            } catch (Exception e) {
                throw new RecordException("Error serializing field " + entry.getKey(), e);
            }
        }

        // Write the fields to delete
        output.writeVInt(record.getFieldsToDelete().size());
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.api.RecordException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.