@Override public LRepository getRepository(String repositoryName) throws RepositoryException, InterruptedException { return repositoryManager.getRepository(repositoryName); }
@Override public LRepository getRepository(String repositoryName) throws InterruptedException, RepositoryException { waitOnRepoManager(); return delegate.getRepository(repositoryName); }
public LRepository getPlainRepository(String repositoryName) throws IOException, InterruptedException, NoServersException, RepositoryException, KeeperException { if (isClosed) { throw new IllegalStateException("This LilyClient is closed."); } return getServerNode().repoMgr.getRepository(repositoryName); }
/** * Returns an LTable that will execute its operations against one specific Lily server, randomly selected from * the available Lily servers. * * <p>This LTable instance will not automatically retry operations and to balance requests * over multiple Lily servers, you need to recall this method regularly to retrieve other * repository instances. Most of the time, you will rather use {@link #getRepository(String)}.</p> */ public LTable getPlainTable(String repositoryName, String tableName) throws IOException, InterruptedException, NoServersException, RepositoryException, KeeperException { if (isClosed) { throw new IllegalStateException("This LilyClient is closed."); } return getServerNode().repoMgr.getRepository(repositoryName).getTable(tableName); }
public IndexInfo(IndexerDefinition indexDefinition, IndexerConf indexerConf, RepositoryManager repositoryManager) throws IndexerConfException, RepositoryException, InterruptedException { this.indexDefinition = indexDefinition; this.indexerConf = indexerConf; String repoParam = indexDefinition.getConnectionParams().get(LResultToSolrMapper.REPO_KEY); LRepository repository = repositoryName == null ? repositoryManager.getDefaultRepository() : repositoryManager.getRepository(repositoryName); repositoryName = repoParam == null ? RepoAndTableUtil.DEFAULT_REPOSITORY : repoParam; this.lilyIndexerConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(indexDefinition.getConfiguration()), repository); }
@Override public List<String> getTables(String repositoryName) throws AvroInterruptedException, AvroIOException, AvroRepositoryException { try { TableManager tableMgr = repositoryManager.getRepository(repositoryName).getTableManager(); List<String> tables = new ArrayList<String>(); for (RepositoryTable table : tableMgr.getTables()) { tables.add(table.getName()); } return tables; } catch (InterruptedException e) { throw converter.convert(e); } catch (IOException e) { throw converter.convert(e); } catch (RepositoryException e) { throw converter.convert(e); } }
@Override public final void processEvents(List<SepEvent> events) { List<LilySepEvent> lilyEvents = new ArrayList<LilySepEvent>(events.size()); for (SepEvent event : events) { if (event.getPayload() == null) { // The event is either not from a Lily table or not a normal record operation. continue; } String[] repoAndTable = RepoAndTableUtil.getRepositoryAndTable(Bytes.toString(event.getTable())); IdGenerator idGenerator = null; try { idGenerator = repositoryManager.getRepository(repoAndTable[0]).getIdGenerator(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } catch (RepositoryUnavailableException e) { log.warn(String.format("Skipping an event because repository is not available. " + "Repository: %s, table: %s, row: %s", repoAndTable[0], repoAndTable[1], Bytes.toStringBinary(event.getRow()))); } catch (RepositoryException e) { throw new RuntimeException(e); } lilyEvents.add(new LilySepEvent(idGenerator, repoAndTable[0], repoAndTable[1], event.getTable(), event.getRow(), event.getKeyValues(), event.getPayload())); } processLilyEvents(lilyEvents); }
private static HBaseRepository createHBaseRepository(String repositoryName, String tableName, ZooKeeperItf zk, Configuration conf, HBaseTableFactory hbaseTableFactory) throws KeeperException, InterruptedException, IOException, RepositoryException { RepositoryModel repositoryModel = new RepositoryModelImpl(zk); IdGenerator idGenerator = new IdGeneratorImpl(); TypeManager typeManager = new HBaseTypeManager(idGenerator, conf, zk, hbaseTableFactory); RecordFactory recordFactory = new RecordFactoryImpl(); RepositoryManager repositoryManager = new HBaseRepositoryManager(typeManager, idGenerator, recordFactory, hbaseTableFactory, new BlobsNotSupportedBlobManager(), conf, repositoryModel); HBaseRepository hbaseRepository; if (tableName != null) { hbaseRepository = (HBaseRepository) repositoryManager.getRepository(repositoryName).getTable(tableName); } else { hbaseRepository = (HBaseRepository) repositoryManager.getRepository(repositoryName); } return hbaseRepository; }
@Override public boolean tableExists(String repositoryName, String name) throws AvroInterruptedException, AvroIOException, AvroRepositoryException { try { TableManager tableMgr = repositoryManager.getRepository(repositoryName).getTableManager(); return tableMgr.tableExists(name); } catch (InterruptedException e) { throw converter.convert(e); } catch (IOException e) { throw converter.convert(e); } catch (RepositoryException e) { throw converter.convert(e); } } }
@Override public Object dropTable(String repositoryName, String name) throws AvroInterruptedException, AvroIOException, AvroRepositoryException { try { TableManager tableMgr = repositoryManager.getRepository(repositoryName).getTableManager(); tableMgr.dropTable(name); return null; } catch (InterruptedException e) { throw converter.convert(e); } catch (IOException e) { throw converter.convert(e); } catch (RepositoryException e) { throw converter.convert(e); } }
@Override public Object createTable(String repository, AvroTableCreateDescriptor tableCreateDescriptor) throws AvroInterruptedException, AvroIOException, AvroRepositoryException { try { TableManager tableMgr = repositoryManager.getRepository(repository).getTableManager(); tableMgr.createTable(converter.convert(tableCreateDescriptor)); return null; } catch (InterruptedException e) { throw converter.convert(e); } catch (IOException e) { throw converter.convert(e); } catch (RepositoryException e) { throw converter.convert(e); } }
@Override public ByteBuffer createOrUpdate(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName, String tableName, boolean useLatestRecordType) throws AvroRepositoryException, AvroInterruptedException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); return converter.convert( table.createOrUpdate(converter.convertRecord(record, repository), useLatestRecordType), repository); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } }
@Override public ByteBuffer create(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName, String tableName) throws AvroRepositoryException, AvroInterruptedException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); return converter.convert(table.create(converter.convertRecord(record, repository)), repository); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } }
@Override public List<String> getVariants(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName, String tableName) throws AvroRepositoryException, AvroInterruptedException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); return converter.convert(table.getVariants(converter.convertAvroRecordId(recordId, repository))); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } }
@Override public ByteBuffer update(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName, String tableName, boolean updateVersion, boolean useLatestRecordType, List<AvroMutationCondition> conditions) throws AvroRemoteException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); return converter.convert(table.update(converter.convertRecord(record, repository), updateVersion, useLatestRecordType, converter.convertFromAvro(conditions, repository)), repository); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } }
@Override public ByteBuffer delete(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName, String tableName, List<AvroMutationCondition> conditions, Map<String,String> attributes) throws AvroRepositoryException, AvroInterruptedException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); RecordId decodedRecordId = converter.convertAvroRecordId(recordId, repository); Record record = null; if (attributes == null) { record = table.delete(decodedRecordId, converter.convertFromAvro(conditions, repository)); } else if (conditions == null) { Record toDelete = table.newRecord(decodedRecordId); toDelete.setAttributes(attributes); table.delete(toDelete); } else { // There is no API call where a full record and MutationConditions can be supplied, so // something has gone wrong if we get here throw new IllegalStateException("Cannot delete a full record with MutationConditions"); } return record == null ? null : converter.convert(record, repository); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } }