Esempio n. 1
0
/** Function called after all items in a tuple have been sent
 * \see oml_writer_row_start
 *
 * Prepare a new marshalled message with sequence and time information in the
 * writer's Mbuffer.
 *
 * This acquires a lock on the BufferedWriter (bw_get_write_buf(...,
 * exclusive=1)).
 *
 * \see BufferedWriter, bw_get_write_buf, marshal_init, marshal_measurements
 * \see gettimeofday(3)
 */
static int
owb_row_start(OmlWriter* writer, OmlMStream* ms, double now)
{
  OmlBinWriter* self = (OmlBinWriter*)writer;
  assert(self->bufferedWriter != NULL);

  MBuffer* mbuf;
  if ((mbuf = self->mbuf = bw_get_write_buf(self->bufferedWriter, 1)) == NULL) {
    return 0;
  }

  marshal_init (mbuf, self->msgtype);
  marshal_measurements(mbuf, ms->index, ms->seq_no, now);
  return 1;
}
Esempio n. 2
0
/**
 * \brief before sending datastore information about the time and the stream
 * \param writer the netwriter to send data
 * \param ms the stream to store the measruement from
 * \param now a timestamp that represensent the current time
 * \return 1 if succesfull, 0 otherwise
 */
int
row_start(OmlWriter* writer, OmlMStream* ms, double now)
{
  OmlTextWriter* self = (OmlTextWriter*)writer;
  assert(self->bufferedWriter != NULL);

  MBuffer* mbuf;
  if ((mbuf = self->mbuf = bw_get_write_buf(self->bufferedWriter, 1)) == NULL)
    return 0;

  mbuf_begin_write(mbuf);
  if (mbuf_print(mbuf, "%f\t%d\t%ld", now, ms->index, ms->seq_no)) {
    mbuf_reset_write(mbuf);
    self->mbuf = NULL;
    return 0;
  }
  return 1;
}