Ejemplo n.º 1
0
  @Override
  public void close() throws IOException {
    zk.removeDefaultWatcher(watcher);

    schemaCache.close();

    for (ServerNode node : servers) {
      Closer.close(node.repository);
    }

    if (managedZk && zk != null) {
      zk.close();
    }

    // Close pools related to the Configuration objects managed by this LilyClient instance
    for (Configuration config : hbaseConnections.getConfigurations()) {
      LocalHTable.closePool(config);
    }

    // Close HBase connections created by [only] this LilyClient instance.
    // This will almost always contain only one connection, if not we would need a more
    // advanced connection mgmt so that these connections don't stay open for the lifetime
    // of LilyClient.
    Closer.close(hbaseConnections);

    this.isClosed = true;
  }
Ejemplo n.º 2
0
  public static BlobManager getBlobManager(ZooKeeperItf zk, HBaseConnections hbaseConns)
      throws IOException {
    Configuration configuration = getHBaseConfiguration(zk);
    // Avoid HBase(Admin)/ZooKeeper connection leaks when using new Configuration objects each time.
    configuration = hbaseConns.getExisting(configuration);
    HBaseTableFactory hbaseTableFactory = new HBaseTableFactoryImpl(configuration);

    URI dfsUri = getDfsUri(zk);
    FileSystem fs = FileSystem.get(DfsUri.getBaseDfsUri(dfsUri), configuration);
    Path blobRootPath = new Path(DfsUri.getDfsPath(dfsUri));

    BlobStoreAccess dfsBlobStoreAccess = new DFSBlobStoreAccess(fs, blobRootPath);
    BlobStoreAccess hbaseBlobStoreAccess = new HBaseBlobStoreAccess(configuration, true);
    BlobStoreAccess inlineBlobStoreAccess = new InlineBlobStoreAccess();
    List<BlobStoreAccess> blobStoreAccesses =
        Arrays.asList(dfsBlobStoreAccess, hbaseBlobStoreAccess, inlineBlobStoreAccess);

    SizeBasedBlobStoreAccessFactory blobStoreAccessFactory =
        new SizeBasedBlobStoreAccessFactory(blobStoreAccesses, getBlobStoreAccessConfig(zk));

    return new BlobManagerImpl(hbaseTableFactory, blobStoreAccessFactory, true);
  }
Ejemplo n.º 3
0
  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;
  }