示例#1
0
  @CliCommand(value = "columns", help = "list all streams querys into engine")
  public String listQuerys(
      @CliOption(
              key = {"stream"},
              help = "The stream name",
              mandatory = true,
              optionContext = "stream")
          final String streamName) {
    // XXX create new renderer to render this table
    try {

      List<ColumnNameTypeValue> columnsValues = ssaw.api().columnsFromStream(streamName);

      List<String> columns = Arrays.asList("Column", "Type");
      List<Map<String, Object>> data = new ArrayList<>();

      for (ColumnNameTypeValue columnValue : columnsValues) {
        Map<String, Object> row = new HashMap<>();
        row.put("Column", columnValue.getColumn());
        row.put("Type", columnValue.getType());

        data.add(row);
      }

      return TableRenderer.renderMapDataAsTable(data, columns);
    } catch (StratioStreamingException e) {
      throw new StreamingShellException(e);
    }
  }
  public int enlargeStream(
      String streamName, List<ColumnNameTypeValue> columns, Boolean raiseException)
      throws ServiceException {
    int addedColumns = 0;
    StreamDefinition streamMetaData = siddhiManager.getStreamDefinition(streamName);
    for (ColumnNameTypeValue columnNameTypeValue : columns) {
      if (!SiddhiUtils.columnAlreadyExistsInStream(
          columnNameTypeValue.getColumn(), streamMetaData)) {
        addedColumns++;
        // JPFM -- Updating the columns in streamStatusDao
        streamStatusDao.addColumn(streamName, columnNameTypeValue);
        streamMetaData.attribute(
            columnNameTypeValue.getColumn(), getSiddhiType(columnNameTypeValue.getType()));
      } else {
        if (raiseException) {
          throw new ServiceException(
              String.format(
                  "Alter stream error, Column %s already " + "exists.",
                  columnNameTypeValue.getColumn()));
        }
      }
    }

    return addedColumns;
  }
 public void createInternalStream(String streamName, List<ColumnNameTypeValue> columns) {
   StreamDefinition newStream = QueryFactory.createStreamDefinition().name(streamName);
   for (ColumnNameTypeValue column : columns) {
     newStream.attribute(column.getColumn(), getSiddhiType(column.getType()));
   }
   siddhiManager.defineStream(newStream);
   streamStatusDao.createInferredStream(streamName, columns);
 }