Exemple #1
0
  @Override
  public long getNumRepos(String username) {
    try {
      THttpClient transport = new THttpClient("http://datahub.csail.mit.edu/service");
      TBinaryProtocol protocol = new TBinaryProtocol(transport);
      DataHub.Client client = new DataHub.Client(protocol);

      ConnectionParams params = new ConnectionParams();
      params.setApp_id(DatahubDataModel.getKibitzAppName());
      params.setApp_token(DatahubDataModel.getKibitzAppId());
      params.setRepo_base(username);
      Connection connection = client.open_connection(params);

      ResultSet res =
          client.execute_sql(
              connection,
              "select count(distinct schemaname) from pg_tables where tableowner = '"
                  + username
                  + "';",
              null);
      HashMap<String, Integer> colToIndex = DatahubDataModel.getFieldNames(res);

      for (Tuple t : res.getTuples()) {
        List<ByteBuffer> cells = t.getCells();
        return Long.parseLong(new String(cells.get(colToIndex.get("count")).array()));
      }
    } catch (DBException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (TException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return 0;
  }
Exemple #2
0
 private void assertThatCountDownLatchEquals(
     final CountDownLatch countDownLatch, final long expectedCountDownValue) {
   assertThat(
       Long.valueOf(countDownLatch.getCount()), equalTo(Long.valueOf(expectedCountDownValue)));
 }