@Override public void delete(Record record) throws RepositoryException, InterruptedException { try { lilyProxy.delete(converter.convert(record.getId()), null, record.getAttributes()); } catch (AvroRepositoryException e) { throw converter.convert(e); } catch (AvroGenericException e) { throw converter.convert(e); } catch (AvroRemoteException e) { throw handleAvroRemoteException(e); } catch (UndeclaredThrowableException e) { throw handleUndeclaredRecordThrowable(e); } }
@Override public Record create(Record record) throws RepositoryException, InterruptedException { try { return converter.convertRecord(lilyProxy.create(converter.convert(record))); } catch (AvroRepositoryException e) { throw converter.convert(e); } catch (AvroGenericException e) { throw converter.convert(e); } catch (AvroRemoteException e) { throw handleAvroRemoteException(e); } catch (UndeclaredThrowableException e) { throw handleUndeclaredRecordThrowable(e); } }
@Override public Set<RecordId> getVariants(RecordId recordId) throws RepositoryException, InterruptedException { try { return converter.convertAvroRecordIds(lilyProxy.getVariants(converter.convert(recordId))); } catch (AvroRepositoryException e) { throw converter.convert(e); } catch (AvroGenericException e) { throw converter.convert(e); } catch (AvroRemoteException e) { throw handleAvroRemoteException(e); } catch (UndeclaredThrowableException e) { throw handleUndeclaredRecordThrowable(e); } }
@Override public Record delete(RecordId recordId, List<MutationCondition> conditions) throws RepositoryException, InterruptedException { try { ByteBuffer record = lilyProxy.delete(converter.convert(recordId), converter.convert(null, conditions), null); return record == null ? null : converter.convertRecord(record); } catch (AvroRepositoryException e) { throw converter.convert(e); } catch (AvroGenericException e) { throw converter.convert(e); } catch (AvroRemoteException e) { throw handleAvroRemoteException(e); } catch (UndeclaredThrowableException e) { throw handleUndeclaredRecordThrowable(e); } }
private RuntimeException handleAvroRemoteException(AvroRemoteException e) throws RecordException { // AvroRemoteException's are exceptions which are not declared in the avro protocol and // which are not RuntimeException's. if (e.getCause() instanceof IOException) { throw new IORecordException(e.getCause()); } else { throw converter.convert(e); } }
@Override public Record update( Record record, boolean updateVersion, boolean useLatestRecordType, List<MutationCondition> conditions) throws RepositoryException, InterruptedException { try { return converter.convertRecord( lilyProxy.update( converter.convert(record), updateVersion, useLatestRecordType, converter.convert(record, conditions))); } catch (AvroRepositoryException e) { throw converter.convert(e); } catch (AvroGenericException e) { throw converter.convert(e); } catch (AvroRemoteException e) { throw handleAvroRemoteException(e); } catch (UndeclaredThrowableException e) { throw handleUndeclaredRecordThrowable(e); } }
private void constructRepository(ServerNode server) throws IOException, InterruptedException, KeeperException, RepositoryException { AvroConverter remoteConverter = new AvroConverter(); IdGeneratorImpl idGenerator = new IdGeneratorImpl(); RemoteTypeManager typeManager = new RemoteTypeManager( parseAddressAndPort(server.lilyAddressAndPort), remoteConverter, idGenerator, zk, schemaCache); // TODO BlobManager can probably be shared across all repositories BlobManager blobManager = getBlobManager(zk, hbaseConnections); Configuration hbaseConf = getHBaseConfiguration(zk); hbaseConf = hbaseConnections.getExisting(hbaseConf); Repository repository = new RemoteRepository( parseAddressAndPort(server.lilyAddressAndPort), remoteConverter, typeManager, idGenerator, blobManager, hbaseConf); remoteConverter.setRepository(repository); if ("true".equals(System.getProperty("lilyclient.trace"))) { repository = TracingRepository.wrap(repository); } typeManager.start(); server.repository = repository; }