[ 
https://issues.apache.org/jira/browse/RYA-487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16472639#comment-16472639
 ] 

ASF GitHub Bot commented on RYA-487:
------------------------------------

Github user kchilton2 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/296#discussion_r187731028
  
    --- Diff: 
extras/kafka.connect/client/src/main/java/org/apache/rya/kafka/connect/client/CLIDriver.java
 ---
    @@ -0,0 +1,121 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.rya.kafka.connect.client;
    +
    +import java.util.Arrays;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.List;
    +import java.util.Set;
    +
    +import 
org.apache.rya.kafka.connect.client.RyaKafkaClientCommand.ArgumentsException;
    +import 
org.apache.rya.kafka.connect.client.RyaKafkaClientCommand.ExecutionException;
    +import org.apache.rya.kafka.connect.client.command.ReadStatementsCommand;
    +import org.apache.rya.kafka.connect.client.command.WriteStatementsCommand;
    +import org.eclipse.rdf4j.model.Statement;
    +
    +import com.google.common.collect.ImmutableMap;
    +import com.google.common.collect.Lists;
    +
    +import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
    +import edu.umd.cs.findbugs.annotations.NonNull;
    +
    +/**
    + * A CLI tool used to read/write {@link Statement}s to/from a Kafka topic 
using the format
    + * the Rya Kafka Connect Sinks expect.
    + */
    +@DefaultAnnotation(NonNull.class)
    +public class CLIDriver {
    +
    +    /**
    +     * Maps from command strings to the object that performs the command.
    +     */
    +    private static final ImmutableMap<String, RyaKafkaClientCommand> 
COMMANDS;
    +    static {
    +        final Set<Class<? extends RyaKafkaClientCommand>> commandClasses = 
new HashSet<>();
    +        commandClasses.add(ReadStatementsCommand.class);
    +        commandClasses.add(WriteStatementsCommand.class);
    +        final ImmutableMap.Builder<String, RyaKafkaClientCommand> builder 
= ImmutableMap.builder();
    +        for(final Class<? extends RyaKafkaClientCommand> commandClass : 
commandClasses) {
    +            try {
    +                final RyaKafkaClientCommand command = 
commandClass.newInstance();
    +                builder.put(command.getCommand(), command);
    +            } catch (InstantiationException | IllegalAccessException e) {
    +                System.err.println("Could not run the application because 
a RyaKafkaClientCommand is missing its empty constructor.");
    +                e.printStackTrace();
    +            }
    +        }
    +        COMMANDS = builder.build();
    +    }
    +
    +    private static final String USAGE = makeUsage(COMMANDS);
    +
    +    public static void main(final String[] args) {
    +        // If no command provided or the command isn't recognized, then 
print the usage.
    +        if (args.length == 0 || !COMMANDS.containsKey(args[0])) {
    +            System.out.println(USAGE);
    +            System.exit(1);
    +        }
    +
    +        // Fetch the command that will be executed.
    +        final String command = args[0];
    +        final String[] commandArgs = Arrays.copyOfRange(args, 1, 
args.length);
    +        final RyaKafkaClientCommand clientCommand = COMMANDS.get(command);
    +
    +        // Print usage if the arguments are invalid for the command.
    +        if(!clientCommand.validArguments(commandArgs)) {
    +            System.out.println(clientCommand.getUsage());
    +            System.exit(1);
    +        }
    +
    +        // Execute the command.
    +            try {
    --- End diff --
    
    Done.


> Kafka Connect Rya Sink
> ----------------------
>
>                 Key: RYA-487
>                 URL: https://issues.apache.org/jira/browse/RYA-487
>             Project: Rya
>          Issue Type: New Feature
>    Affects Versions: 4.0.0
>            Reporter: Kevin Chilton
>            Assignee: Kevin Chilton
>            Priority: Major
>             Fix For: 4.0.0
>
>
> Implement a Kafka Connect Sink that writes to Rya.
> This sink does not have to handle visibilities.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to