@Override public int hashCode() { return Objects.hash(getTopic(), getFromBeginning(), getIntervalValue()); }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof PrintTopic)) { return false; } final PrintTopic that = (PrintTopic) o; return getFromBeginning() == that.getFromBeginning() && Objects.equals(getTopic(), that.getTopic()) && getIntervalValue() == that.getIntervalValue(); }
private Response handlePrintTopic(final PreparedStatement<PrintTopic> statement) { final PrintTopic printTopic = statement.getStatement(); final String topicName = printTopic.getTopic().toString(); if (!serviceContext.getTopicClient().isTopicExists(topicName)) { throw new KsqlRestException( Errors.badRequest(String.format( "Could not find topic '%s', " + "or the KSQL user does not have permissions to list the topic." + System.lineSeparator() + "KSQL will treat unquoted topic names as uppercase." + System.lineSeparator() + "To print a case-sensitive topic use quotes, for example: print \'Topic\';", topicName))); } final TopicStreamWriter topicStreamWriter = new TopicStreamWriter( serviceContext.getSchemaRegistryClient(), ksqlConfig.getKsqlStreamConfigProps(), topicName, printTopic.getIntervalValue(), disconnectCheckInterval, printTopic.getFromBeginning() ); log.info("Printing topic '{}'", topicName); return Response.ok().entity(topicStreamWriter).build(); } }
private void handlePrintTopic(final SessionAndRequest info, final PrintTopic printTopic) { final String topicName = printTopic.getTopic().toString(); if (!serviceContext.getTopicClient().isTopicExists(topicName)) { throw new IllegalArgumentException( "Topic does not exist, or KSQL does not have permission to list the topic: " + topicName); } final WebSocketSubscriber<String> topicSubscriber = new WebSocketSubscriber<>(info.session, mapper); this.subscriber = topicSubscriber; topicPublisher.start(exec, serviceContext.getSchemaRegistryClient(), ksqlConfig.getKsqlStreamConfigProps(), topicName, printTopic.getFromBeginning(), topicSubscriber ); }