congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
StreamsQuery
Code IndexAdd Tabnine to your IDE (free)

How to use
StreamsQuery
in
org.apache.rya.streams.api.entity

Best Java code snippets using org.apache.rya.streams.api.entity.StreamsQuery (Showing top 13 results out of 315)

origin: apache/incubator-rya

/**
 * Pretty formats a {@link StreamsQuery}.
 *
 * @param query - The query to format. (not null)
 * @return The pretty formatted string.
 * @throws Exception A problem was encountered while pretty formatting the SPARQL.
 */
public static String format(final StreamsQuery query) throws Exception {
  requireNonNull(query);
  // Pretty format the SPARQL query.
  final ParsedQuery parsedQuery = new SPARQLParser().parseQuery(query.getSparql(), null);
  final String prettySparql = new SPARQLQueryRenderer().render(parsedQuery);
  final String[] lines = prettySparql.split("\n");
  // Create the formatted string.
  query.getQueryId();
  query.isActive();
  String.format(" QueryId: %s", query.getQueryId());
  final StringBuilder builder = new StringBuilder();
  builder.append(" Query ID: ").append( query.getQueryId() ) .append("\n");
  builder.append("Is Active: ").append( query.isActive() ).append("\n");
  builder.append("Is Insert: ").append( query.isInsert() ).append("\n");
  builder.append("   SPARQL: ").append( lines[0] ).append("\n");
  for(int i = 1; i < lines.length; i++) {
    builder.append("           ").append(lines[i]).append("\n");
  }
  return builder.toString();
}
origin: apache/incubator-rya

private void append(final StringBuilder string, final StreamsQuery query) {
  requireNonNull(string);
  requireNonNull(query);
  string.append("    Streams Query {\n")
     .append("        Query ID: ").append(query.getQueryId()).append(",\n")
     .append("        Is Active: ").append(query.isActive()).append(",\n")
     .append("        SPARQL: ").append(query.getSparql()).append("\n")
     .append("    }");
}
origin: apache/incubator-rya

  @Override
  public KafkaStreams make(final String ryaInstance, final StreamsQuery query) throws KafkaStreamsFactoryException {
    requireNonNull(ryaInstance);
    requireNonNull(query);

    // Setup the Kafka Stream program.
    final Properties streamsProps = new Properties();

    // Configure the Kafka servers that will be talked to.
    streamsProps.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServersConfig);

    // Use the Query ID as the Application ID to ensure we resume where we left off the last time this command was run.
    streamsProps.put(StreamsConfig.APPLICATION_ID_CONFIG, "RyaStreams-Query-" + query.getQueryId());

    // Always start at the beginning of the input topic.
    streamsProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");

    // Setup the topology that processes the Query.
    final String statementsTopic = KafkaTopics.statementsTopic(ryaInstance);
    final String resultsTopic = KafkaTopics.queryResultsTopic(ryaInstance, query.getQueryId());

    try {
      final TopologyBuilder topologyBuilder = topologyFactory.build(query.getSparql(), statementsTopic, resultsTopic, new RandomUUIDFactory());
      return new KafkaStreams(topologyBuilder, new StreamsConfig(streamsProps));
    } catch (final MalformedQueryException | TopologyBuilderException e) {
      throw new KafkaStreamsFactoryException("Could not create a KafkaStreams processing topology for query " + query.getQueryId(), e);
    }
  }
}
origin: apache/incubator-rya

final StreamsQuery query = new StreamsQuery(
    queryId,
    change.getSparql().get(),
if(queriesCache.containsKey(queryId)) {
  final StreamsQuery old = queriesCache.get(queryId);
  final StreamsQuery updated = new StreamsQuery(
      old.getQueryId(),
      old.getSparql(),
      change.getIsActive().get(),
      old.isInsert());
  queriesCache.put(queryId, updated);
origin: org.apache.rya/rya.streams.api

final StreamsQuery query = new StreamsQuery(
    queryId,
    change.getSparql().get(),
if(queriesCache.containsKey(queryId)) {
  final StreamsQuery old = queriesCache.get(queryId);
  final StreamsQuery updated = new StreamsQuery(
      old.getQueryId(),
      old.getSparql(),
      change.getIsActive().get());
  queriesCache.put(queryId, updated);
origin: apache/incubator-rya

  log.info("Rya Instance " + ryaInstance + " created Rya Streams query " + newQueryState + ".");
  final StreamsQuery newQuery = newQueryState.get();
  if(newQuery.isActive()) {
    final QueryEvent executeNewQuery = QueryEvent.executing(ryaInstance, newQuery);
    offerUntilAcceptedOrShutdown(queryWorkQueue, executeNewQuery, blockingValue, blockingUnits, shutdownSignal);
if(newQueryState.isPresent()) {
  final StreamsQuery updatedQuery = newQueryState.get();
  if(updatedQuery.isActive()) {
    log.info("Rya Instance " + ryaInstance + " updated Rya Streams query with ID " +
        updatedQuery.getQueryId() + " to be active.");
    final QueryEvent executeUpdatedQuery = QueryEvent.executing(ryaInstance, updatedQuery);
    offerUntilAcceptedOrShutdown(queryWorkQueue, executeUpdatedQuery, blockingValue, blockingUnits, shutdownSignal);
  } else {
    log.info("Rya Instance " + ryaInstance + " updated Rya Streams query with ID " +
        updatedQuery.getQueryId() + " to be inactive.");
    final QueryEvent stopUpdatedQuery = QueryEvent.stopped(ryaInstance, updatedQuery.getQueryId());
    offerUntilAcceptedOrShutdown(queryWorkQueue, stopUpdatedQuery, blockingValue, blockingUnits, shutdownSignal);
origin: apache/incubator-rya

  final String id1 = query1.getQueryId().toString();
  final String id2 = query2.getQueryId().toString();
  return id1.compareTo(id2);
});
origin: apache/incubator-rya

final String sparql = query.get().getSparql();
final TopologyBuilder topologyBuilder;
try {
origin: apache/incubator-rya

@CliCommand(value = STREAM_QUERIES_START_CMD, help = "Start processing a SPARQL query using the Rya Streams subsystem.")
public String startQuery(
    @CliOption(key= {"queryId"}, mandatory = true, help = "The ID of the query to start processing.")
    final String queryId) {
  final RyaStreamsClient streamsClient = state.getShellState().getRyaStreamsCommands().get();
  try {
    // Ensure the query exists.
    final UUID id = UUID.fromString(queryId);
    final java.util.Optional<StreamsQuery> streamsQuery = streamsClient.getGetQuery().getQuery(id);
    if(!streamsQuery.isPresent()) {
      throw new RuntimeException("No Rya Streams query exists for ID " + queryId);
    }
    // Ensure it isn't already started.
    if(streamsQuery.get().isActive()) {
      return "That query is already running.";
    }
    // Start it.
    streamsClient.getStartQuery().start(id);
    return "The query will be processed by the Rya Streams subsystem.";
  } catch (final RyaStreamsException e) {
    throw new RuntimeException("Unable to start the Query.", e);
  }
}
origin: apache/incubator-rya

.forEach(query -> {
  final QueryEvent queryEvent = query.isActive() ?
      QueryEvent.executing(ryaInstance, query) : QueryEvent.stopped(ryaInstance, query.getQueryId());
  log.debug("LogEventWorker - offering: " + queryEvent);
origin: apache/incubator-rya

@Override
public void startQuery(final String ryaInstance, final StreamsQuery query) throws QueryExecutorException {
  requireNonNull(ryaInstance);
  requireNonNull(query);
  checkState(state() == State.RUNNING, "The service must be RUNNING to execute this method.");
  lock.lock();
  try {
    // Make sure the Statements topic exists for the query.
    final Set<String> topics = Sets.newHashSet(
        KafkaTopics.statementsTopic(ryaInstance),
        KafkaTopics.queryResultsTopic(ryaInstance, query.getQueryId()));
    // Make sure the Query Results topic exists for the query.
    // Since this is running in the JVM, the properties are left empty
    //   so the cleanup.policy will default to delete to reduce memory usage.
    createKafkaTopic.createTopics(topics, 1, 1, Optional.empty());
    // Setup the Kafka Streams job that will execute.
    final KafkaStreams streams = streamsFactory.make(ryaInstance, query);
    streams.start();
    // Mark which Rya Instance the Query ID is for.
    ryaInstanceById.put(query.getQueryId(), ryaInstance);
    // Add the Query ID to the collection of running queries for the Rya instance.
    idByRyaInstance.put(ryaInstance, query.getQueryId());
    // Add the running Kafka Streams job for the Query ID.
    byQueryId.put(query.getQueryId(), streams);
  } catch (final KafkaStreamsFactoryException e) {
    throw new QueryExecutorException("Could not start query " + query.getQueryId(), e);
  } finally {
    lock.unlock();
  }
}
origin: apache/incubator-rya

@CliCommand(value = STREAM_QUERIES_STOP_CMD, help = "Stop processing a SPARQL query using the Rya Streams subsystem.")
public String stopQuery(
    @CliOption(key= {"queryId"}, mandatory = true, help = "The ID of the query to stop processing.")
    final String queryId) {
  final RyaStreamsClient streamsClient = state.getShellState().getRyaStreamsCommands().get();
  try {
    // Ensure the query exists.
    final UUID id = UUID.fromString(queryId);
    final java.util.Optional<StreamsQuery> streamsQuery = streamsClient.getGetQuery().getQuery(id);
    if(!streamsQuery.isPresent()) {
      throw new RuntimeException("No Rya Streams query exists for ID " + queryId);
    }
    // Ensure it isn't already stopped.
    if(!streamsQuery.get().isActive()) {
      return "That query is already stopped.";
    }
    // Stop it.
    streamsClient.getStopQuery().stop(id);
    return "The query will no longer be processed by the Rya Streams subsystem.";
  } catch (final RyaStreamsException e) {
    throw new RuntimeException("Unable to start the Query.", e);
  }
}
origin: apache/incubator-rya

return "The added query's ID is " + streamsQuery.getQueryId();
org.apache.rya.streams.api.entityStreamsQuery

Javadoc

A SPARQL query that is being processed within Rya Streams.

Most used methods

  • getQueryId
  • getSparql
  • isActive
  • isInsert
  • <init>
    Constructs an instance of StreamsQuery.

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • getResourceAsStream (ClassLoader)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now