@Override public LRepository getRepository(String repositoryName) throws RepositoryException, InterruptedException { return repositoryManager.getRepository(repositoryName); }
@Override public LRepository getDefaultRepository() throws InterruptedException, RepositoryException { return repositoryManager.getDefaultRepository(); }
@Override public void close() throws IOException { synchronized (delegateAvailable) { if (delegate != null) { delegate.close(); } } }
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 LRepository getRepository(String repositoryName) throws InterruptedException, RepositoryException { waitOnRepoManager(); return delegate.getRepository(repositoryName); }
@Override public LRepository getDefaultRepository() throws InterruptedException, RepositoryException { waitOnRepoManager(); return delegate.getDefaultRepository(); }
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); }
private IdGenerator getIdGenerator() throws InterruptedException, LinkIndexException { // synchronization not an issue, doesn't matter if this happens twice // can't assign IdGenerator in constructor since the repository is a premature one if (lazyIdGenerator == null) { try { lazyIdGenerator = repositoryManager.getDefaultRepository().getIdGenerator(); } catch (RepositoryException e) { throw new LinkIndexException(e); } } return lazyIdGenerator; }
/** * 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 void processEvent(LilySepEvent event) { LRepository repository = null; try { repository = repositoryManager.getDefaultRepository(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } catch (RepositoryException e) { throw new RuntimeException(e); } RecordEvent recordEvent; try { recordEvent = event.getRecordEvent(); } catch (IOException e) { log.error("Error reading record event, processing of message cancelled", e); return; } AbsoluteRecordId absoluteRecordId = event.getAbsoluteRecordId(); update(absoluteRecordId, recordEvent); }
@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); } }
@PostConstruct public void start() throws IOException, RepositoryException, InterruptedException { AvroLilyImpl avroLily = new AvroLilyImpl(repositoryManager, repositoryManager.getDefaultRepository().getTypeManager()); Responder responder = new LilySpecificResponder(AvroLily.class, avroLily); ThreadFactory threadFactory = new CustomThreadFactory("avro-exechandler", new ThreadGroup("AvroExecHandler")); if (maxServerThreads == -1) { executorService = Executors.newCachedThreadPool(threadFactory); executionHandler = new ExecutionHandler(executorService); } else { executorService = new ThreadPoolExecutor(maxServerThreads / 3, maxServerThreads, 60, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), threadFactory, new WaitPolicy()); executionHandler = new ExecutionHandler(executorService); } //server = new HttpServer(responder, port); server = new NettyServer(responder, new InetSocketAddress(port), new NioServerSocketChannelFactory (Executors.newCachedThreadPool(), Executors.newCachedThreadPool()), executionHandler); server.start(); }
@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 Set<FieldedLink> extractLinks(VTaggedRecord vtRecord, Long version) { long before = System.currentTimeMillis(); try { Set<FieldedLink> links; IdRecord versionRecord = null; try { versionRecord = vtRecord.getIdRecord(version); } catch (RecordNotFoundException e) { // vtag points to a non-existing record } if (versionRecord == null) { links = Collections.emptySet(); } else { LRepository repository = repositoryManager.getDefaultRepository(); LinkCollector collector = new LinkCollector(repository.getIdGenerator()); RecordLinkExtractor.extract(versionRecord, collector, repository); links = collector.getLinks(); } return links; } catch (VersionNotFoundException e) { // A vtag pointing to a non-existing version, nothing unusual. return Collections.emptySet(); } catch (Throwable t) { log.error("Error extracting links from record " + vtRecord.getId(), t); } finally { metrics.report(Action.EXTRACT, System.currentTimeMillis() - before); } return Collections.emptySet(); }
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; }
/** * Lookup name of field type, for use in debug logs. Beware, this might be slow. */ private String safeLoadTagName(SchemaId fieldTypeId) { if (fieldTypeId == null) { return "null"; } try { return repositoryManager.getDefaultRepository().getTypeManager().getFieldTypeById(fieldTypeId).getName().getName(); } catch (Throwable t) { return "failed to load name"; } }
@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); } }
repositoryManager.getDefaultRepository().getTypeManager()); LRepository repository = repositoryManager.getDefaultRepository(); LTable table = repository.getTable(recordEvent.getTableName()); vtRecord = new VTaggedRecord(absRecordId.getRecordId(), eventHelper, table, repository);
@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 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); } }