Пример #1
0
  private void loadPartitions(DboTableMeta meta2) {
    DboTableMeta tableMeta = mgr.find(DboTableMeta.class, "partitions");
    NoSqlSession session = mgr.getSession();
    byte[] rowKey = StandardConverters.convertToBytes(meta2.getColumnFamily());
    Cursor<Column> results =
        session.columnSlice(tableMeta, rowKey, null, null, 1000, BigInteger.class);

    while (results.next()) {
      Column col = results.getCurrent();
      BigInteger time = StandardConverters.convertFromBytes(BigInteger.class, col.getName());
      existingPartitions.add(time.longValue());
    }

    Collections.sort(existingPartitions);
  }
Пример #2
0
  public void monitorFired(NoSqlEntityManager mgr, PlayOrmCronJob mon) {
    String mode = Play.configuration.getProperty("upgrade.mode");
    if ("NEW".equals(mode) || StringUtils.isEmpty(mode)) {
      runNewCode(mgr, mon);
      return;
    }

    TableMonitor tableMon = TableMonitor.copy(mon);
    if (log.isInfoEnabled()) log.info("monitor firing(old version)=" + tableMon);

    String tableName = tableMon.getTableName();
    // NOTE: d.time>0 is here because PlayOrm does not yet have order by asc(time) which would
    // choose the index
    // so instead PlayOrm randomly chooses an index
    String sql = "select d from " + tableName + " as d where d.time>0";
    NoSqlTypedSession s = mgr.getTypedSession();
    QueryResult result = s.createQueryCursor(sql, 1); // only need last
    // point so batch
    // size of 1

    Cursor<KeyValue<TypedRow>> cursor = result.getPrimaryViewCursor();
    TypedRow r = getLastVal(cursor);
    DateTime now = new DateTime();
    if (r == null) {
      fireEmailStreamIsDown("old", null, now, tableMon);
      return;
    }

    BigInteger timestamp = (BigInteger) r.getRowKey();

    runDataCheck("old", tableMon, now, timestamp.longValue());
  }
Пример #3
0
  protected AbstractCursor<Column> getCursorWithResults() {
    if (cursor != null && cursor.next()) {
      return cursor;
    } else if (currentIndex >= existingPartitions.size()) return null;

    int count = 0;
    do {
      Long currentPartId = existingPartitions.get(currentIndex);
      NoSqlTypedSession em = mgr.getTypedSession();
      NoSqlSession raw = em.getRawSession();

      byte[] rowKeyPostFix =
          meta.getIdColumnMeta().convertToStorage2(new BigInteger("" + currentPartId));
      byte[] rowKey = meta.getIdColumnMeta().formVirtRowKey(rowKeyPostFix);
      cursor = raw.columnSlice(meta, rowKey, startBytes, endBytes, 500, BigInteger.class);
      currentIndex++;
      if (cursor.next()) return cursor;
      count++;

    } while (!hasReachedEnd(end));

    // reached end and no data found
    return null;
  }