Esempio n. 1
0
  public byte[] readFromTable(String key) {
    String q1 = "SELECT * FROM kaltura_live.log_data WHERE id = '" + key + "';";

    ResultSet results = cassandraSession.getSession().execute(q1);
    for (Row row : results) {
      ByteBuffer data = row.getBytes("data");
      byte[] result = new byte[data.remaining()];
      data.get(result);
      return result;
    }
    return null;
  }
Esempio n. 2
0
 public void insertIntoTable(String key, byte[] data) {
   try {
     Date hourKey = getFileDateTime(key);
     PreparedStatement statement =
         cassandraSession
             .getSession()
             .prepare(
                 "INSERT INTO kaltura_live.log_data (file_id,data) VALUES (?, ?) USING TTL ?");
     BoundStatement boundStatement = new BoundStatement(statement);
     cassandraSession.execute(boundStatement.bind(key, ByteBuffer.wrap(data), LOGS_TTL), RETRIES);
     statement =
         cassandraSession
             .getSession()
             .prepare(
                 "INSERT INTO kaltura_live.log_files (hour_id,file_id) VALUES (?, ?) USING TTL ?");
     boundStatement = new BoundStatement(statement);
     cassandraSession.execute(boundStatement.bind(hourKey, key, LOGS_TTL), RETRIES);
   } catch (Exception ex) {
     LOG.error("Failed to insert log file: " + key, ex);
   }
 }