You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by ca...@apache.org on 2017/08/03 17:25:12 UTC
[2/2] incubator-rya git commit: RYA-318 Rya Shell improvements for
packaging, loading and querying.
RYA-318 Rya Shell improvements for packaging, loading and querying.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/fa2aad55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/fa2aad55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/fa2aad55
Branch: refs/heads/master
Commit: fa2aad55f4dfd4f78cc1b6b2da39b511ce206a8d
Parents: 65f6d47
Author: jdasch <jd...@localhost.localdomain>
Authored: Thu Jul 27 11:00:52 2017 -0400
Committer: Caleb Meier <ca...@parsons.com>
Committed: Thu Aug 3 10:23:56 2017 -0700
----------------------------------------------------------------------
.../rya/api/client/ExecuteSparqlQuery.java | 39 +++
.../org/apache/rya/api/client/RyaClient.java | 14 +-
extras/indexing/pom.xml | 341 ++++++++++---------
.../accumulo/AccumuloConnectionDetails.java | 23 +-
.../accumulo/AccumuloExecuteSparqlQuery.java | 181 ++++++++++
.../api/client/accumulo/AccumuloInstall.java | 11 +-
.../accumulo/AccumuloLoadStatementsFile.java | 19 +-
.../accumulo/AccumuloRyaClientFactory.java | 3 +-
.../accumulo/AccumuloLoadStatementsFileIT.java | 2 +-
extras/rya.console/pom.xml | 33 +-
.../src/main/assembly/binary-release.xml | 33 ++
.../src/main/assembly/component-release.xml | 90 +++++
.../src/main/config/log4j.properties | 35 ++
.../rya.console/src/main/examples/Query1.sparql | 24 ++
.../src/main/examples/example.script | 26 ++
extras/rya.console/src/main/examples/triples.nt | 25 ++
.../org/apache/rya/shell/RyaAdminCommands.java | 84 ++++-
.../java/org/apache/rya/shell/RyaCommands.java | 166 +++++++++
.../apache/rya/shell/RyaConnectionCommands.java | 25 +-
.../rya/shell/RyaShellHistoryProvider.java | 51 +++
.../apache/rya/shell/util/ConsolePrinter.java | 85 +++++
.../apache/rya/shell/util/InstallPrompt.java | 32 +-
.../org/apache/rya/shell/util/JLinePrompt.java | 16 +-
.../org/apache/rya/shell/util/SparqlPrompt.java | 44 ++-
.../META-INF/spring/spring-shell-plugin.xml | 10 +
extras/rya.console/src/main/scripts/rya | 33 ++
.../apache/rya/shell/RyaAdminCommandsTest.java | 120 ++++++-
.../org/apache/rya/shell/RyaCommandsTest.java | 278 +++++++++++++++
.../rya/shell/RyaConnectionCommandsIT.java | 31 +-
.../src/test/resources/Query1.sparql | 20 ++
.../src/test/resources/RyaShellTest-context.xml | 6 +
pom.xml | 10 +
32 files changed, 1638 insertions(+), 272 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/common/rya.api/src/main/java/org/apache/rya/api/client/ExecuteSparqlQuery.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/client/ExecuteSparqlQuery.java b/common/rya.api/src/main/java/org/apache/rya/api/client/ExecuteSparqlQuery.java
new file mode 100644
index 0000000..817b752
--- /dev/null
+++ b/common/rya.api/src/main/java/org/apache/rya/api/client/ExecuteSparqlQuery.java
@@ -0,0 +1,39 @@
+/**
+ * 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.api.client;
+
+import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
+import edu.umd.cs.findbugs.annotations.NonNull;
+
+/**
+ * Loads a SPARQL Query and executes the query against an instance of Rya.
+ */
+@DefaultAnnotation(NonNull.class)
+public interface ExecuteSparqlQuery {
+ /**
+ * Loads a SPARQL Query and executes the query against an instance of Rya.
+ *
+ * @param ryaInstanceName - The name of the Rya instance the query will be executed against. (not null)
+ * @param sparqlQuery - A single SPARQL Query. (not null)
+ * @return A user-friendly String representation of the query results.
+ * @throws InstanceDoesNotExistException No instance of Rya exists for the provided name.
+ * @throws RyaClientException Something caused the command to fail.
+ */
+ public String executeSparqlQuery(String ryaInstanceName, String sparqlQuery) throws InstanceDoesNotExistException, RyaClientException;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/common/rya.api/src/main/java/org/apache/rya/api/client/RyaClient.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/client/RyaClient.java b/common/rya.api/src/main/java/org/apache/rya/api/client/RyaClient.java
index 9e0ef4f..d1481dc 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/client/RyaClient.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/client/RyaClient.java
@@ -42,6 +42,7 @@ public class RyaClient {
private final RemoveUser removeUser;
private final Uninstall uninstall;
private final LoadStatementsFile loadStatementsFile;
+ private final ExecuteSparqlQuery executeSparqlQuery;
/**
* Constructs an instance of {@link RyaClient}.
@@ -57,7 +58,8 @@ public class RyaClient {
final AddUser addUser,
final RemoveUser removeUser,
final Uninstall uninstall,
- final LoadStatementsFile loadStatementsFile) {
+ final LoadStatementsFile loadStatementsFile,
+ final ExecuteSparqlQuery executeSparqlQuery) {
this.install = requireNonNull(install);
this.createPcj = requireNonNull(createPcj);
this.deletePcj = requireNonNull(deletePcj);
@@ -68,7 +70,8 @@ public class RyaClient {
this.addUser = requireNonNull(addUser);
this.removeUser = requireNonNull(removeUser);
this.uninstall = requireNonNull(uninstall);
- this.loadStatementsFile = requireNonNull( loadStatementsFile );
+ this.loadStatementsFile = requireNonNull(loadStatementsFile);
+ this.executeSparqlQuery = requireNonNull(executeSparqlQuery);
}
/**
@@ -150,4 +153,11 @@ public class RyaClient {
public LoadStatementsFile getLoadStatementsFile() {
return loadStatementsFile;
}
+
+ /**
+ * @return An instance of {@link ExecuteSparqlQuery} that is connected to a Rya storage.
+ */
+ public ExecuteSparqlQuery getExecuteSparqlQuery() {
+ return executeSparqlQuery;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/indexing/pom.xml
----------------------------------------------------------------------
diff --git a/extras/indexing/pom.xml b/extras/indexing/pom.xml
index 755646c..44e3e41 100644
--- a/extras/indexing/pom.xml
+++ b/extras/indexing/pom.xml
@@ -1,103 +1,109 @@
<?xml version='1.0'?>
<!-- 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. -->
+ 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. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.extras</artifactId>
- <version>3.2.11-incubating-SNAPSHOT</version>
- </parent>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.rya</groupId>
+ <artifactId>rya.extras</artifactId>
+ <version>3.2.11-incubating-SNAPSHOT</version>
+ </parent>
- <artifactId>rya.indexing</artifactId>
- <name>Apache Rya Secondary Indexing</name>
+ <artifactId>rya.indexing</artifactId>
+ <name>Apache Rya Secondary Indexing</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
+ </properties>
- <dependencies>
-
- <dependency>
- <groupId>org.apache.accumulo</groupId>
- <artifactId>accumulo-minicluster</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.sail</artifactId>
- <exclusions>
- <exclusion>
- <artifactId>hsqldb</artifactId>
- <groupId>hsqldb</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>accumulo.rya</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>mongodb.rya</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.prospector</artifactId>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.rya</groupId>
+ <artifactId>rya.sail</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>hsqldb</artifactId>
+ <groupId>hsqldb</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.rya</groupId>
+ <artifactId>accumulo.rya</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.rya</groupId>
+ <artifactId>mongodb.rya</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.rya</groupId>
+ <artifactId>rya.prospector</artifactId>
+ </dependency>
- <!-- Free Text Indexing -->
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-analyzers</artifactId>
- </dependency>
+ <!-- Free Text Indexing -->
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-analyzers</artifactId>
+ </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
- <!-- PCJ Indexing -->
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.indexing.pcj</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.pcj.fluo.api</artifactId>
- </dependency>
+ <!-- PCJ Indexing -->
+ <dependency>
+ <groupId>org.apache.rya</groupId>
+ <artifactId>rya.indexing.pcj</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.rya</groupId>
+ <artifactId>rya.pcj.fluo.api</artifactId>
+ </dependency>
+
+ <!-- OpenRDF -->
+ <dependency>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-queryresultio-text</artifactId>
+ </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
+ <!-- testing dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.accumulo</groupId>
+ <artifactId>accumulo-minicluster</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.fluo</groupId>
<artifactId>fluo-mini</artifactId>
@@ -117,86 +123,89 @@
<scope>test</scope>
<type>test-jar</type>
</dependency>
- </dependencies>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <!-- RDF data Files -->
- <exclude>**/*.ttl</exclude>
+
+ </dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- RDF data Files -->
+ <exclude>**/*.ttl</exclude>
- <!-- Services Files -->
- <exclude>**/resources/META-INF/services/**</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <configuration>
- <shadedArtifactAttached>true</shadedArtifactAttached>
- <shadedClassifierName>map-reduce</shadedClassifierName>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
- </transformers>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- </execution>
- <execution>
- <id>accumulo-server</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <shadedArtifactAttached>true</shadedArtifactAttached>
- <shadedClassifierName>accumulo-server</shadedClassifierName>
- <artifactSet>
- <excludes>
- <exclude>org.locationtech.geomesa:*</exclude>
- <exclude>mil.nga.giat:*</exclude>
- <exclude>scala:*</exclude>
- <exclude>org.apache.accumulo:*</exclude>
- <exclude>org.apache.thrift:*</exclude>
- <exclude>org.apache.hadoop:*</exclude>
- <exclude>org.apache.zookeeper:*</exclude>
- </excludes>
- </artifactSet>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
- </transformers>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <!-- Services Files -->
+ <exclude>**/resources/META-INF/services/**</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <configuration>
+ <shadedArtifactAttached>true</shadedArtifactAttached>
+ <shadedClassifierName>map-reduce</shadedClassifierName>
+ <transformers>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+ </transformers>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA</exclude>
+ <exclude>META-INF/*.RSA</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ </execution>
+ <execution>
+ <id>accumulo-server</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedArtifactAttached>true</shadedArtifactAttached>
+ <shadedClassifierName>accumulo-server</shadedClassifierName>
+ <artifactSet>
+ <excludes>
+ <exclude>org.locationtech.geomesa:*</exclude>
+ <exclude>mil.nga.giat:*</exclude>
+ <exclude>scala:*</exclude>
+ <exclude>org.apache.accumulo:*</exclude>
+ <exclude>org.apache.thrift:*</exclude>
+ <exclude>org.apache.hadoop:*</exclude>
+ <exclude>org.apache.zookeeper:*</exclude>
+ </excludes>
+ </artifactSet>
+ <transformers>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+ </transformers>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA</exclude>
+ <exclude>META-INF/*.RSA</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloConnectionDetails.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloConnectionDetails.java b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloConnectionDetails.java
index f3753a8..c0759c4 100644
--- a/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloConnectionDetails.java
+++ b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloConnectionDetails.java
@@ -20,6 +20,8 @@ package org.apache.rya.api.client.accumulo;
import static java.util.Objects.requireNonNull;
+import org.apache.rya.accumulo.AccumuloRdfConfiguration;
+
import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
import edu.umd.cs.findbugs.annotations.NonNull;
import net.jcip.annotations.Immutable;
@@ -33,7 +35,7 @@ public class AccumuloConnectionDetails {
private final String username;
private final char[] password;
private final String instanceName;
- private final String zookeepers;
+ private final String zookeepers;
/**
* Constructs an instance of {@link AccumuloConnectionDetails}.
@@ -81,4 +83,23 @@ public class AccumuloConnectionDetails {
public String getZookeepers() {
return zookeepers;
}
+
+ /**
+ *
+ * @param ryaInstanceName - The Rya instance to connect to.
+ * @return Constructs a new {@link AccumuloRdfConfiguration} object with values from this object.
+ */
+ public AccumuloRdfConfiguration buildAccumuloRdfConfiguration(final String ryaInstanceName) {
+
+ // Note, we don't use the AccumuloRdfConfigurationBuilder here because it explicitly sets
+ // authorizations and visibilities to an empty string if they are not set on the builder.
+ // If they are null in the AccumuloRdfConfiguration object, then Accumulo uses the values stored in accumulo for the user.
+ final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
+ conf.setTablePrefix(ryaInstanceName);
+ conf.setAccumuloZookeepers(zookeepers);
+ conf.setAccumuloInstance(instanceName);
+ conf.setAccumuloUser(username);
+ conf.setAccumuloPassword(new String(password));
+ return conf;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloExecuteSparqlQuery.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloExecuteSparqlQuery.java b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloExecuteSparqlQuery.java
new file mode 100644
index 0000000..f3e50d0
--- /dev/null
+++ b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloExecuteSparqlQuery.java
@@ -0,0 +1,181 @@
+/**
+ * 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.api.client.accumulo;
+
+import static java.util.Objects.requireNonNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.text.DecimalFormat;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.log4j.Logger;
+import org.apache.rya.accumulo.AccumuloRdfConfiguration;
+import org.apache.rya.api.client.ExecuteSparqlQuery;
+import org.apache.rya.api.client.InstanceDoesNotExistException;
+import org.apache.rya.api.client.InstanceExists;
+import org.apache.rya.api.client.RyaClientException;
+import org.apache.rya.api.persist.RyaDAOException;
+import org.apache.rya.rdftriplestore.inference.InferenceEngineException;
+import org.apache.rya.sail.config.RyaSailFactory;
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.MalformedQueryException;
+import org.openrdf.query.QueryEvaluationException;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.query.TupleQuery;
+import org.openrdf.query.TupleQueryResultHandlerException;
+import org.openrdf.query.resultio.text.csv.SPARQLResultsCSVWriter;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.repository.sail.SailRepositoryConnection;
+import org.openrdf.sail.Sail;
+import org.openrdf.sail.SailException;
+
+import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
+import edu.umd.cs.findbugs.annotations.NonNull;
+
+/**
+ * An Accumulo implementation of the {@link ExecuteSparqlQuery} command.
+ */
+@DefaultAnnotation(NonNull.class)
+public class AccumuloExecuteSparqlQuery extends AccumuloCommand implements ExecuteSparqlQuery {
+ private static final Logger log = Logger.getLogger(AccumuloExecuteSparqlQuery.class);
+
+ private final InstanceExists instanceExists;
+
+ /**
+ * Constructs an instance of {@link AccumuloExecuteSparqlQuery}.
+ *
+ * @param connectionDetails - Details about the values that were used to create
+ * the connector to the cluster. (not null)
+ * @param connector - Provides programmatic access to the instance of Accumulo
+ * that hosts Rya instance. (not null)
+ */
+ public AccumuloExecuteSparqlQuery(final AccumuloConnectionDetails connectionDetails, final Connector connector) {
+ super(connectionDetails, connector);
+ instanceExists = new AccumuloInstanceExists(connectionDetails, connector);
+ }
+
+
+ @Override
+ public String executeSparqlQuery(final String ryaInstanceName, final String sparqlQuery)
+ throws InstanceDoesNotExistException, RyaClientException {
+ requireNonNull(ryaInstanceName);
+ requireNonNull(sparqlQuery);
+
+ // Ensure the Rya Instance exists.
+ if(!instanceExists.exists(ryaInstanceName)) {
+ throw new InstanceDoesNotExistException(String.format("There is no Rya instance named '%s'.", ryaInstanceName));
+ }
+
+
+ Sail sail = null;
+ SailRepository sailRepo = null;
+ SailRepositoryConnection sailRepoConn = null;
+
+ try {
+ // Get a Sail object that is connected to the Rya instance.
+ final AccumuloRdfConfiguration ryaConf = getAccumuloConnectionDetails().buildAccumuloRdfConfiguration(ryaInstanceName);
+ sail = RyaSailFactory.getInstance(ryaConf);
+ sailRepo = new SailRepository(sail);
+ sailRepoConn = sailRepo.getConnection();
+
+ // Execute the query.
+ final long start = System.currentTimeMillis();
+ final TupleQuery tupleQuery = sailRepoConn.prepareTupleQuery(QueryLanguage.SPARQL, sparqlQuery);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final CountingSPARQLResultsCSVWriter handler = new CountingSPARQLResultsCSVWriter(baos);
+ tupleQuery.evaluate(handler);
+ final StringBuilder sb = new StringBuilder();
+
+ final String newline = "\n";
+ sb.append("Query Result:").append(newline);
+ sb.append(new String(baos.toByteArray(), StandardCharsets.UTF_8));
+
+ final String seconds = new DecimalFormat("0.0##").format((System.currentTimeMillis() - start) / 1000.0);
+ sb.append("Retrieved ").append(handler.getCount()).append(" results in ").append(seconds).append(" seconds.");
+
+ return sb.toString();
+
+ } catch (final SailException | AccumuloException | AccumuloSecurityException | RyaDAOException | InferenceEngineException e) {
+ throw new RyaClientException("A problem connecting to the Rya instance named '" + ryaInstanceName + "' has caused the query to fail.", e);
+ } catch (final MalformedQueryException e) {
+ throw new RyaClientException("There was a problem parsing the supplied query.", e);
+ } catch (final QueryEvaluationException | TupleQueryResultHandlerException e) {
+ throw new RyaClientException("There was a problem evaluating the supplied query.", e);
+ } catch (final RepositoryException e) {
+ throw new RyaClientException("There was a problem executing the query against the Rya instance named " + ryaInstanceName + ".", e);
+ } finally {
+ // Shut it all down.
+ if(sailRepoConn != null) {
+ try {
+ sailRepoConn.close();
+ } catch (final RepositoryException e) {
+ log.warn("Couldn't close the SailRepoConnection that is attached to the Rya instance.", e);
+ }
+ }
+ if(sailRepo != null) {
+ try {
+ sailRepo.shutDown();
+ } catch (final RepositoryException e) {
+ log.warn("Couldn't shut down the SailRepository that is attached to the Rya instance.", e);
+ }
+ }
+ if(sail != null) {
+ try {
+ sail.shutDown();
+ } catch (final SailException e) {
+ log.warn("Couldn't shut down the Sail that is attached to the Rya instance.", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Subclasses {@link SPARQLResultsCSVWriter} to keep track of the total count of handled {@link BindingSet} objects.
+ */
+ private static class CountingSPARQLResultsCSVWriter extends SPARQLResultsCSVWriter {
+
+ private int count = 0;
+
+ /**
+ * @param out - The OutputStream for results to be written to.
+ */
+ public CountingSPARQLResultsCSVWriter(final OutputStream out) {
+ super(out);
+ }
+ @Override
+ public void handleSolution(final BindingSet bindingSet) throws TupleQueryResultHandlerException {
+ super.handleSolution(bindingSet);
+ count++;
+ }
+
+ /**
+ *
+ * @return The number of BindingSets that were handled by {@link #handleSolution(BindingSet)}.
+ */
+ public int getCount() {
+ return count;
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloInstall.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloInstall.java b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloInstall.java
index 6fd0d36..65661d2 100644
--- a/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloInstall.java
+++ b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloInstall.java
@@ -22,9 +22,6 @@ import static java.util.Objects.requireNonNull;
import java.util.Date;
-import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
-import edu.umd.cs.findbugs.annotations.NonNull;
-
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
@@ -55,6 +52,9 @@ import org.openrdf.sail.SailException;
import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
+import edu.umd.cs.findbugs.annotations.NonNull;
+
/**
* An Accumulo implementation of the {@link Install} command.
*/
@@ -194,6 +194,11 @@ public class AccumuloInstall extends AccumuloCommand implements Install {
* RYA-215
* conf.set(ConfigUtils.USE_GEO, "" + details.getGeoIndexDetails().isEnabled() );
*/
+
+ /**
+ * RYA-322
+ * conf.setPrefixRowsWithHash(details.getPrefixRowsWithHashDetails().isEnabled());
+ */
conf.set(ConfigUtils.USE_FREETEXT, "" + details.getFreeTextIndexDetails().isEnabled() );
conf.set(ConfigUtils.USE_TEMPORAL, "" + details.getTemporalIndexDetails().isEnabled() );
conf.set(ConfigUtils.USE_ENTITY, "" + details.getEntityCentricIndexDetails().isEnabled());
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFile.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFile.java b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFile.java
index f39951d..182432a 100644
--- a/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFile.java
+++ b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFile.java
@@ -33,7 +33,6 @@ import org.apache.rya.api.client.InstanceExists;
import org.apache.rya.api.client.LoadStatementsFile;
import org.apache.rya.api.client.RyaClientException;
import org.apache.rya.api.persist.RyaDAOException;
-import org.apache.rya.indexing.accumulo.ConfigUtils;
import org.apache.rya.rdftriplestore.inference.InferenceEngineException;
import org.apache.rya.sail.config.RyaSailFactory;
import org.openrdf.repository.RepositoryException;
@@ -41,6 +40,7 @@ import org.openrdf.repository.sail.SailRepository;
import org.openrdf.repository.sail.SailRepositoryConnection;
import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.RDFParseException;
+import org.openrdf.rio.UnsupportedRDFormatException;
import org.openrdf.sail.Sail;
import org.openrdf.sail.SailException;
@@ -86,25 +86,20 @@ public class AccumuloLoadStatementsFile extends AccumuloCommand implements LoadS
try {
// Get a Sail object that is connected to the Rya instance.
- final AccumuloConnectionDetails connDetails = getAccumuloConnectionDetails();
-
- final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration();
- ryaConf.setTablePrefix( ryaInstanceName );
- ryaConf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, connDetails.getZookeepers());
- ryaConf.set(ConfigUtils.CLOUDBASE_INSTANCE, connDetails.getInstanceName());
- ryaConf.set(ConfigUtils.CLOUDBASE_USER, connDetails.getUsername());
- ryaConf.set(ConfigUtils.CLOUDBASE_PASSWORD, new String(connDetails.getPassword()));
-
+ final AccumuloRdfConfiguration ryaConf = getAccumuloConnectionDetails().buildAccumuloRdfConfiguration(ryaInstanceName);
+ ryaConf.setFlush(false); //RYA-327 should address this hardcoded value.
sail = RyaSailFactory.getInstance(ryaConf);
// Load the file.
- sailRepo = new SailRepository( sail );
+ sailRepo = new SailRepository(sail);
sailRepoConn = sailRepo.getConnection();
sailRepoConn.add(statementsFile.toFile(), null, format);
} catch (final SailException | AccumuloException | AccumuloSecurityException | RyaDAOException | InferenceEngineException e) {
+ log.warn("Exception while loading:", e);
throw new RyaClientException("A problem connecting to the Rya instance named '" + ryaInstanceName + "' has caused the load to fail.", e);
- } catch (final RepositoryException | RDFParseException | IOException e) {
+ } catch (final RepositoryException | RDFParseException | UnsupportedRDFormatException | IOException e) {
+ log.warn("Exception while loading:", e);
throw new RyaClientException("A problem processing the RDF file has caused the load into Rya instance named " + ryaInstanceName + "to fail.", e);
} finally {
// Shut it all down.
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloRyaClientFactory.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloRyaClientFactory.java b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloRyaClientFactory.java
index b9742b0..5ee02f9 100644
--- a/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloRyaClientFactory.java
+++ b/extras/indexing/src/main/java/org/apache/rya/api/client/accumulo/AccumuloRyaClientFactory.java
@@ -59,6 +59,7 @@ public class AccumuloRyaClientFactory {
new AccumuloAddUser(connectionDetails, connector),
new AccumuloRemoveUser(connectionDetails, connector),
new AccumuloUninstall(connectionDetails, connector),
- new AccumuloLoadStatementsFile(connectionDetails, connector));
+ new AccumuloLoadStatementsFile(connectionDetails, connector),
+ new AccumuloExecuteSparqlQuery(connectionDetails, connector));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java
index a4ec09c..f5d1923 100644
--- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java
+++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java
@@ -123,7 +123,7 @@ public class AccumuloLoadStatementsFileIT extends AccumuloITBase {
assertEquals(expected, statements);
}
- private boolean isRyaMetadataStatement(ValueFactory vf, Statement statement) {
+ private boolean isRyaMetadataStatement(final ValueFactory vf, final Statement statement) {
return statement.getPredicate().equals( vf.createURI("urn:org.apache.rya/2012/05#version") ) ||
statement.getPredicate().equals( vf.createURI("urn:org.apache.rya/2012/05#rts") );
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/pom.xml
----------------------------------------------------------------------
diff --git a/extras/rya.console/pom.xml b/extras/rya.console/pom.xml
index a9b9030..dec339b 100644
--- a/extras/rya.console/pom.xml
+++ b/extras/rya.console/pom.xml
@@ -33,6 +33,10 @@
<dependencies>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.rya</groupId>
<artifactId>rya.api</artifactId>
</dependency>
@@ -54,18 +58,19 @@
<groupId>org.apache.rya</groupId>
<artifactId>rya.pcj.fluo.api</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.fluo</groupId>
+ <artifactId>fluo-core</artifactId>
+ </dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell</artifactId>
</dependency>
-
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
-
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -79,7 +84,6 @@
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-minicluster</artifactId>
- <version>${accumulo.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -136,7 +140,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
- <version>2.0</version>
<executions>
<execution>
<phase>package</phase>
@@ -151,6 +154,7 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.springframework.shell.Bootstrap</mainClass>
</transformer>
@@ -174,11 +178,28 @@
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-binary-distribution</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/binary-release.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
<!-- Generate Code Coverage report. -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
- <version>0.7.6.201602180812</version>
<executions>
<execution>
<id>default-prepare-agent</id>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/assembly/binary-release.xml
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/assembly/binary-release.xml b/extras/rya.console/src/main/assembly/binary-release.xml
new file mode 100644
index 0000000..374213f
--- /dev/null
+++ b/extras/rya.console/src/main/assembly/binary-release.xml
@@ -0,0 +1,33 @@
+<!--
+
+ 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.
+
+-->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
+ <id>bin</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <componentDescriptors>
+ <componentDescriptor>src/main/assembly/component-release.xml</componentDescriptor>
+ </componentDescriptors>
+</assembly>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/assembly/component-release.xml
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/assembly/component-release.xml b/extras/rya.console/src/main/assembly/component-release.xml
new file mode 100644
index 0000000..72c74d1
--- /dev/null
+++ b/extras/rya.console/src/main/assembly/component-release.xml
@@ -0,0 +1,90 @@
+<!--
+
+ 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.
+
+-->
+<component
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3 http://maven.apache.org/xsd/component-1.1.3.xsd">
+ <fileSets>
+ <fileSet>
+ <directory>src/main/config</directory>
+ <outputDirectory>conf</outputDirectory>
+ <directoryMode>0755</directoryMode>
+ <fileMode>0644</fileMode>
+ <lineEnding>unix</lineEnding>
+ <filtered>false</filtered>
+ <includes>
+ <include>*.properties</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/scripts</directory>
+ <outputDirectory>bin</outputDirectory>
+ <directoryMode>0755</directoryMode>
+ <fileMode>0755</fileMode>
+ <includes>
+ <include>rya</include>
+ </includes>
+ <lineEnding>unix</lineEnding>
+ <filtered>true</filtered>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/scripts</directory>
+ <outputDirectory>bin</outputDirectory>
+ <directoryMode>0755</directoryMode>
+ <fileMode>0644</fileMode>
+ <includes>
+ <include>*.bat</include>
+ </includes>
+ <lineEnding>dos</lineEnding>
+ <filtered>true</filtered>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/examples</directory>
+ <outputDirectory>examples</outputDirectory>
+ <directoryMode>0755</directoryMode>
+ <fileMode>0644</fileMode>
+ <!-- <includes> <include>*.script</include> </includes> -->
+ <lineEnding>unix</lineEnding>
+ <filtered>false</filtered>
+ </fileSet>
+
+ <!-- create an empty directory for log files -->
+ <fileSet>
+ <directory>src/main/assembly</directory>
+ <outputDirectory>logs</outputDirectory>
+ <directoryMode>755</directoryMode>
+ <excludes>
+ <exclude>*</exclude>
+ </excludes>
+ </fileSet>
+
+
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>lib</outputDirectory>
+ <directoryMode>755</directoryMode>
+ <fileMode>0644</fileMode>
+ <includes>
+ <include>${project.artifactId}-${project.version}-shaded.jar</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/config/log4j.properties
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/config/log4j.properties b/extras/rya.console/src/main/config/log4j.properties
new file mode 100644
index 0000000..49d6822
--- /dev/null
+++ b/extras/rya.console/src/main/config/log4j.properties
@@ -0,0 +1,35 @@
+#
+# 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.
+#
+
+# Valid levels:
+# TRACE, DEBUG, INFO, WARN, ERROR and FATAL
+log4j.rootCategory=INFO, LOGFILE
+
+# LOGFILE is set to be a File appender using a PatternLayout.
+log4j.appender.LOGFILE=org.apache.log4j.FileAppender
+log4j.appender.LOGFILE.File=${rya.shell.home}logs/rya-shell.log
+#log4j.appender.LOGFILE.Threshold=DEBUG
+log4j.appender.LOGFILE.Append=true
+
+log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+
+#log4j.appender.LOGFILE.layout=org.apache.log4j.EnhancedPatternLayout
+#log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c{1.} - %m%n
+
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/examples/Query1.sparql
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/examples/Query1.sparql b/extras/rya.console/src/main/examples/Query1.sparql
new file mode 100644
index 0000000..33619fb
--- /dev/null
+++ b/extras/rya.console/src/main/examples/Query1.sparql
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+SELECT ?thing ?name WHERE {
+ ?thing <http://predicates#name> ?name .
+ ?thing rdf:type <http://types#Monkey> .
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/examples/example.script
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/examples/example.script b/extras/rya.console/src/main/examples/example.script
new file mode 100644
index 0000000..529ea61
--- /dev/null
+++ b/extras/rya.console/src/main/examples/example.script
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+connect-accumulo --username accumulo_user --instanceName accumulo_instance --zookeepers zoo1,zoo2,zoo3,zoo4,zoo5
+install-with-parameters --instanceName rya_example_
+connect-rya --instance rya_example_
+#load-data --file examples/ontology.owl
+load-data --file examples/triples.nt
+sparql-query --file examples/Query1.sparql
+# uninstall
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/examples/triples.nt
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/examples/triples.nt b/extras/rya.console/src/main/examples/triples.nt
new file mode 100644
index 0000000..38b6c6f
--- /dev/null
+++ b/extras/rya.console/src/main/examples/triples.nt
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+
+<http://Thing1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://types#Monkey> .
+<http://Thing1> <http://predicates#name> "Thing 1".
+<http://Thing2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://types#Gorilla> .
+<http://Thing2> <http://predicates#name> "Thing 2".
+<http://Thing3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://types#Monkey> .
+<http://Thing3> <http://predicates#name> "Thing 3".
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/java/org/apache/rya/shell/RyaAdminCommands.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaAdminCommands.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaAdminCommands.java
index 5493170..9239dc7 100644
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaAdminCommands.java
+++ b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaAdminCommands.java
@@ -55,8 +55,9 @@ public class RyaAdminCommands implements CommandMarker {
public static final String CREATE_PCJ_CMD = "create-pcj";
public static final String DELETE_PCJ_CMD = "delete-pcj";
- public static final String GET_INSTANCE_DETAILS_CMD = "get-instance-details";
+ public static final String PRINT_INSTANCE_DETAILS_CMD = "print-instance-details";
public static final String INSTALL_CMD = "install";
+ public static final String INSTALL_PARAMETERS_CMD = "install-with-parameters";
public static final String LIST_INSTANCES_CMD = "list-instances";
public static final String UNINSTALL_CMD = "uninstall";
public static final String ADD_USER_CMD = "add-user";
@@ -107,7 +108,7 @@ public class RyaAdminCommands implements CommandMarker {
* Enables commands that are always available once the Shell is connected to a Rya Instance.
*/
@CliAvailabilityIndicator({
- GET_INSTANCE_DETAILS_CMD,
+ PRINT_INSTANCE_DETAILS_CMD,
UNINSTALL_CMD,
ADD_USER_CMD,
REMOVE_USER_CMD})
@@ -171,7 +172,7 @@ public class RyaAdminCommands implements CommandMarker {
}
}
- @CliCommand(value = INSTALL_CMD, help = "Create a new instance of Rya.")
+ @CliCommand(value = INSTALL_CMD, help = "Create a new instance of Rya interactively.")
public String install() {
// Fetch the commands that are connected to the store.
final RyaClient commands = state.getShellState().getConnectedCommands().get();
@@ -183,7 +184,7 @@ public class RyaAdminCommands implements CommandMarker {
while(!verified) {
// Use the install prompt to fetch the user's installation options.
instanceName = installPrompt.promptInstanceName();
- installConfig = installPrompt.promptInstallConfiguration();
+ installConfig = installPrompt.promptInstallConfiguration(instanceName);
// Verify the configuration is what the user actually wants to do.
verified = installPrompt.promptVerified(instanceName, installConfig);
@@ -200,8 +201,65 @@ public class RyaAdminCommands implements CommandMarker {
}
}
- @CliCommand(value = GET_INSTANCE_DETAILS_CMD, help = "Print information about how the Rya instance is configured.")
- public String getInstanceDetails() {
+ @CliCommand(value = INSTALL_PARAMETERS_CMD, help = "Create a new instance of Rya with command line parameters.")
+ public String installWithParameters(
+ @CliOption(key = {"instanceName"}, mandatory = true, help = "The name of the Rya instance to create.")
+ final String instanceName,
+
+ @CliOption(key = {"enableTableHashPrefix"}, mandatory = false, help = "Use Shard Balancing (improves streamed input write speeds).", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
+ final boolean enableTableHashPrefix,
+
+ @CliOption(key = {"enableEntityCentricIndex"}, mandatory = false, help = "Use Entity Centric Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
+ final boolean enableEntityCentricIndex,
+
+ @CliOption(key = {"enableFreeTextIndex"}, mandatory = false, help = "Use Free Text Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
+ final boolean enableFreeTextIndex,
+
+ @CliOption(key = {"enableGeospatialIndex"}, mandatory = false, help = "Use Geospatial Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
+ final boolean enableGeospatialIndex,
+
+ @CliOption(key = {"enableTemporalIndex"}, mandatory = false, help = "Use Temporal Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
+ final boolean enableTemporalIndex,
+
+ @CliOption(key = {"enablePcjIndex"}, mandatory = false, help = "Use Precomputed Join (PCJ) Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
+ final boolean enablePcjIndex,
+
+ @CliOption(key = {"fluoPcjAppName"}, mandatory = false, help = "Fluo Application Name for PCJ Index Updater (fluo app must be initialized and enablePcjIndex=true).")
+ final String fluoPcjAppName
+ ) {
+
+ // Fetch the commands that are connected to the store.
+ final RyaClient commands = state.getShellState().getConnectedCommands().get();
+
+ try {
+ final InstallConfiguration installConfig = InstallConfiguration.builder()
+ .setEnableTableHashPrefix(enableTableHashPrefix)
+ .setEnableEntityCentricIndex(enableEntityCentricIndex)
+ .setEnableFreeTextIndex(enableFreeTextIndex)
+ .setEnableGeoIndex(enableGeospatialIndex)
+ .setEnableTemporalIndex(enableTemporalIndex)
+ .setEnablePcjIndex(enablePcjIndex)
+ .setFluoPcjAppName(fluoPcjAppName)
+ .build();
+
+ // Verify the configuration is what the user actually wants to do.
+ if (!installPrompt.promptVerified(instanceName, installConfig)) {
+ return "Skipping Installation.";
+ }
+
+ // Execute the command.
+ commands.getInstall().install(instanceName, installConfig);
+ return String.format("The Rya instance named '%s' has been installed.", instanceName);
+
+ } catch(final DuplicateInstanceNameException e) {
+ throw new RuntimeException(String.format("A Rya instance named '%s' already exists. Try again with a different name.", instanceName), e);
+ } catch (final IOException | RyaClientException e) {
+ throw new RuntimeException("Could not install a new instance of Rya. Reason: " + e.getMessage(), e);
+ }
+ }
+
+ @CliCommand(value = PRINT_INSTANCE_DETAILS_CMD, help = "Print information about how the Rya instance is configured.")
+ public String printInstanceDetails() {
// Fetch the command that is connected to the store.
final ShellState shellState = state.getShellState();
final RyaClient commands = shellState.getConnectedCommands().get();
@@ -230,11 +288,15 @@ public class RyaAdminCommands implements CommandMarker {
try {
// Prompt the user for the SPARQL.
- final String sparql = sparqlPrompt.getSparql();
- // Execute the command.
- final String pcjId = commands.getCreatePCJ().createPCJ(ryaInstance, sparql);
- // Return a message that indicates the ID of the newly created ID.
- return String.format("The PCJ has been created. Its ID is '%s'.", pcjId);
+ final Optional<String> sparql = sparqlPrompt.getSparql();
+ if (sparql.isPresent()) {
+ // Execute the command.
+ final String pcjId = commands.getCreatePCJ().createPCJ(ryaInstance, sparql.get());
+ // Return a message that indicates the ID of the newly created ID.
+ return String.format("The PCJ has been created. Its ID is '%s'.", pcjId);
+ } else {
+ return ""; // user aborted the SPARQL prompt.
+ }
} catch (final InstanceDoesNotExistException e) {
throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstance), e);
} catch (final IOException | RyaClientException e) {
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/java/org/apache/rya/shell/RyaCommands.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaCommands.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaCommands.java
new file mode 100644
index 0000000..09ee410
--- /dev/null
+++ b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaCommands.java
@@ -0,0 +1,166 @@
+/**
+ * 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.shell;
+
+import static java.util.Objects.requireNonNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.text.DecimalFormat;
+import java.util.Objects;
+
+import org.apache.rya.api.client.RyaClient;
+import org.apache.rya.api.client.RyaClientException;
+import org.apache.rya.shell.SharedShellState.ShellState;
+import org.apache.rya.shell.util.ConsolePrinter;
+import org.apache.rya.shell.util.SparqlPrompt;
+import org.openrdf.rio.RDFFormat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+import org.springframework.stereotype.Component;
+
+import com.google.common.base.Optional;
+
+/**
+ * Rya Shell commands that have to do with common tasks (loading and querying data)
+ */
+@Component
+public class RyaCommands implements CommandMarker {
+
+ private static final Logger log = LoggerFactory.getLogger(RyaCommands.class);
+
+ public static final String LOAD_DATA_CMD = "load-data";
+ public static final String SPARQL_QUERY_CMD = "sparql-query";
+
+ private final SharedShellState state;
+ private final SparqlPrompt sparqlPrompt;
+ private final ConsolePrinter consolePrinter;
+
+ /**
+ * Constructs an instance of {@link RyaCommands}.
+ *
+ * @param state - Holds shared state between all of the command classes. (not null)
+ * @param sparqlPrompt - Prompts a user for a SPARQL query. (not null)
+ * @param consolePrinter - Allows the command to print feedback to the user. (not null)
+ */
+ @Autowired
+ public RyaCommands(final SharedShellState state, final SparqlPrompt sparqlPrompt,
+ final ConsolePrinter consolePrinter) {
+ this.state = Objects.requireNonNull(state);
+ this.sparqlPrompt = requireNonNull(sparqlPrompt);
+ this.consolePrinter = Objects.requireNonNull(consolePrinter);
+ }
+
+ /**
+ * Enables commands that are always available once the Shell is connected to a Rya Instance.
+ */
+ @CliAvailabilityIndicator({ LOAD_DATA_CMD, SPARQL_QUERY_CMD })
+ public boolean areInstanceCommandsAvailable() {
+ switch (state.getShellState().getConnectionState()) {
+ case CONNECTED_TO_INSTANCE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @CliCommand(value = LOAD_DATA_CMD, help = "Loads RDF Statement data from a local file to the connected Rya instance.")
+ public String loadData(
+ @CliOption(key = { "file" }, mandatory = true, help = "A local file containing RDF Statements that is to be loaded.")
+ final String file,
+ @CliOption(key = { "format" }, mandatory = false, help = "The format of the supplied RDF Statements file. [RDF/XML, N-Triples, Turtle, N3, TriX, TriG, BinaryRDF, N-Quads, JSON-LD, RDF/JSON, RDFa]")
+ final String format
+ ) {
+ // Fetch the command that is connected to the store.
+ final ShellState shellState = state.getShellState();
+ final RyaClient commands = shellState.getConnectedCommands().get();
+ final Optional<String> ryaInstanceName = shellState.getRyaInstanceName();
+ try {
+ final long start = System.currentTimeMillis();
+ final File rdfInputFile = new File(file);
+
+ RDFFormat rdfFormat = null;
+ if (format != null) {
+ rdfFormat = RDFFormat.valueOf(format);
+ if (rdfFormat == null) {
+ throw new RuntimeException("Unsupported RDF Statement data input format: " + format);
+ }
+ }
+ if (rdfFormat == null) {
+ rdfFormat = RDFFormat.forFileName(rdfInputFile.getName());
+ if (rdfFormat == null) {
+ throw new RuntimeException("Unable to detect RDF Statement data input format for file: " + rdfInputFile);
+ } else {
+ consolePrinter.println("Detected RDF Format: " + rdfFormat);
+ consolePrinter.flush();
+ }
+ }
+ commands.getLoadStatementsFile().loadStatements(ryaInstanceName.get(), rdfInputFile.toPath(), rdfFormat);
+
+ final String seconds = new DecimalFormat("0.0##").format((System.currentTimeMillis() - start) / 1000.0);
+ return "Loaded the file: '" + file + "' successfully in " + seconds + " seconds.";
+
+ } catch (final RyaClientException | IOException e) {
+ log.error("Error", e);
+ throw new RuntimeException("Can not load the RDF Statement data. Reason: " + e.getMessage(), e);
+ }
+ }
+
+ @CliCommand(value = SPARQL_QUERY_CMD, help = "Executes the provided SPARQL Query on the connected Rya instance.")
+ public String sparqlQuery(
+ @CliOption(key = { "file" }, mandatory = false, help = "A local file containing the SPARQL Query that is to be read and executed.")
+ final String file) {
+ // Fetch the command that is connected to the store.
+ final ShellState shellState = state.getShellState();
+ final RyaClient commands = shellState.getConnectedCommands().get();
+ final Optional<String> ryaInstanceName = shellState.getRyaInstanceName();
+
+ try {
+ // file option specified
+ String sparqlQuery;
+ if (file != null) {
+ sparqlQuery = new String(Files.readAllBytes(new File(file).toPath()), StandardCharsets.UTF_8);
+ consolePrinter.println("Loaded Query:");
+ consolePrinter.println(sparqlQuery);
+ } else {
+ // No Options specified. Show the user the SPARQL Prompt
+ final Optional<String> sparqlQueryOpt = sparqlPrompt.getSparql();
+ if (sparqlQueryOpt.isPresent()) {
+ sparqlQuery = sparqlQueryOpt.get();
+ } else {
+ return ""; // user aborted the SPARQL prompt.
+ }
+ }
+
+ consolePrinter.println("Executing Query...");
+ consolePrinter.flush();
+ return commands.getExecuteSparqlQuery().executeSparqlQuery(ryaInstanceName.get(), sparqlQuery);
+ } catch (final RyaClientException | IOException e) {
+ log.error("Error", e);
+ throw new RuntimeException("Can not execute the SPARQL Query. Reason: " + e.getMessage(), e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/java/org/apache/rya/shell/RyaConnectionCommands.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaConnectionCommands.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaConnectionCommands.java
index a5debc2..f5ba451 100644
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaConnectionCommands.java
+++ b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaConnectionCommands.java
@@ -26,6 +26,14 @@ import java.nio.CharBuffer;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
+import org.apache.rya.api.client.InstanceExists;
+import org.apache.rya.api.client.RyaClient;
+import org.apache.rya.api.client.RyaClientException;
+import org.apache.rya.api.client.accumulo.AccumuloConnectionDetails;
+import org.apache.rya.api.client.accumulo.AccumuloRyaClientFactory;
+import org.apache.rya.shell.SharedShellState.ConnectionState;
+import org.apache.rya.shell.util.ConnectorFactory;
+import org.apache.rya.shell.util.PasswordPrompt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
@@ -35,15 +43,6 @@ import org.springframework.stereotype.Component;
import com.google.common.base.Optional;
-import org.apache.rya.api.client.InstanceExists;
-import org.apache.rya.api.client.RyaClientException;
-import org.apache.rya.api.client.RyaClient;
-import org.apache.rya.api.client.accumulo.AccumuloConnectionDetails;
-import org.apache.rya.api.client.accumulo.AccumuloRyaClientFactory;
-import org.apache.rya.shell.SharedShellState.ConnectionState;
-import org.apache.rya.shell.util.ConnectorFactory;
-import org.apache.rya.shell.util.PasswordPrompt;
-
/**
* Spring Shell commands that manage the connection that is used by the shell.
*/
@@ -53,7 +52,7 @@ public class RyaConnectionCommands implements CommandMarker {
// Command line commands.
public static final String PRINT_CONNECTION_DETAILS_CMD = "print-connection-details";
public static final String CONNECT_ACCUMULO_CMD = "connect-accumulo";
- public static final String CONNECT_INSTANCE_CMD = "connect-to-instance";
+ public static final String CONNECT_INSTANCE_CMD = "connect-rya";
public static final String DISCONNECT_COMMAND_NAME_CMD = "disconnect";
private final SharedShellState sharedState;
@@ -139,9 +138,9 @@ public class RyaConnectionCommands implements CommandMarker {
return "Connected. You must select a Rya instance to interact with next.";
}
- @CliCommand(value = CONNECT_INSTANCE_CMD, help = "Connect to a specific ")
+ @CliCommand(value = CONNECT_INSTANCE_CMD, help = "Connect to a specific Rya instance")
public void connectToInstance(
- @CliOption(key = {"instance"}, mandatory = true, help = "The name of the Rya Instance the shell will interact with.")
+ @CliOption(key = {"instance"}, mandatory = true, help = "The name of the Rya instance the shell will interact with.")
final String instance) {
try {
final InstanceExists instanceExists = sharedState.getShellState().getConnectedCommands().get().getInstanceExists();
@@ -160,7 +159,7 @@ public class RyaConnectionCommands implements CommandMarker {
sharedState.connectedToInstance(instance);
}
- @CliCommand(value = DISCONNECT_COMMAND_NAME_CMD, help = "Disconnect the shell from the Rya storage it is connect to.")
+ @CliCommand(value = DISCONNECT_COMMAND_NAME_CMD, help = "Disconnect the shell's Rya storage connection (Accumulo).")
public void disconnect() {
sharedState.disconnected();
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/java/org/apache/rya/shell/RyaShellHistoryProvider.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/RyaShellHistoryProvider.java b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaShellHistoryProvider.java
new file mode 100644
index 0000000..b4ade8f
--- /dev/null
+++ b/extras/rya.console/src/main/java/org/apache/rya/shell/RyaShellHistoryProvider.java
@@ -0,0 +1,51 @@
+/**
+ * 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.shell;
+
+import java.io.File;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.shell.plugin.HistoryFileNameProvider;
+import org.springframework.stereotype.Component;
+
+/**
+ * Customizes the Rya Shell's history file.
+ */
+@Component
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class RyaShellHistoryProvider implements HistoryFileNameProvider {
+
+ public static final String RYA_SHELL_HISTORY_FILENAME = ".rya_shell_history";
+
+ @Override
+ public String getHistoryFileName() {
+ final String userHome = System.getProperty("user.home");
+ if(userHome == null) {
+ return RYA_SHELL_HISTORY_FILENAME;
+ } else {
+ return new File(userHome, RYA_SHELL_HISTORY_FILENAME).getAbsolutePath();
+ }
+ }
+
+ @Override
+ public String getProviderName() {
+ return this.getClass().getSimpleName();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/java/org/apache/rya/shell/util/ConsolePrinter.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/util/ConsolePrinter.java b/extras/rya.console/src/main/java/org/apache/rya/shell/util/ConsolePrinter.java
new file mode 100644
index 0000000..4492a87
--- /dev/null
+++ b/extras/rya.console/src/main/java/org/apache/rya/shell/util/ConsolePrinter.java
@@ -0,0 +1,85 @@
+/**
+ * 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.shell.util;
+
+import java.io.IOException;
+
+import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
+import edu.umd.cs.findbugs.annotations.NonNull;
+import jline.console.ConsoleReader;
+
+/**
+ * A mechanism for printing content to the console.
+ */
+@DefaultAnnotation(NonNull.class)
+public interface ConsolePrinter {
+
+ /**
+ * Prints the provided content to the console.
+ * @param cs - Output the specified String to the console.
+ * @throws IOException There was a problem reading the user's input.
+ */
+ public void print(CharSequence cs) throws IOException;
+
+ /**
+ * Prints the provided content to the console with a newline.
+ * @param cs - Output the specified String to the console.
+ * @throws IOException There was a problem reading the user's input.
+ */
+ public void println(CharSequence cs) throws IOException;
+
+ /**
+ * Prints a newline.
+ * @throws IOException There was a problem reading the user's input.
+ */
+ public void println() throws IOException;
+
+ /**
+ * Flush any pending console updates to the console output stream.
+ * @throws IOException
+ */
+ public void flush() throws IOException;
+
+ /**
+ * Prints to the console using a JLine {@link ConsoleReader}.
+ */
+ @DefaultAnnotation(NonNull.class)
+ public static class JLineConsolePrinter extends JLinePrompt implements ConsolePrinter {
+
+ @Override
+ public void print(final CharSequence cs) throws IOException {
+ getReader().print(cs);
+ }
+
+ @Override
+ public void println(final CharSequence cs) throws IOException {
+ getReader().println(cs);
+ }
+
+ @Override
+ public void println() throws IOException {
+ getReader().println();
+ }
+
+ @Override
+ public void flush() throws IOException {
+ getReader().flush();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/fa2aad55/extras/rya.console/src/main/java/org/apache/rya/shell/util/InstallPrompt.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/org/apache/rya/shell/util/InstallPrompt.java b/extras/rya.console/src/main/java/org/apache/rya/shell/util/InstallPrompt.java
index 397deca..5d9d48b 100644
--- a/extras/rya.console/src/main/java/org/apache/rya/shell/util/InstallPrompt.java
+++ b/extras/rya.console/src/main/java/org/apache/rya/shell/util/InstallPrompt.java
@@ -20,10 +20,11 @@ package org.apache.rya.shell.util;
import java.io.IOException;
+import org.apache.rya.api.client.Install.InstallConfiguration;
+
import com.google.common.base.Optional;
import jline.console.ConsoleReader;
-import org.apache.rya.api.client.Install.InstallConfiguration;
/**
* A mechanism for prompting a user of the application for a the parameters
@@ -42,10 +43,11 @@ public interface InstallPrompt {
/**
* Prompt the user for which features of Rya they want enabled.
*
+ * @param instanceName - The Rya instance name.
* @return The value they entered.
* @throws IOException There was a problem reading the values.
*/
- public InstallConfiguration promptInstallConfiguration() throws IOException;
+ public InstallConfiguration promptInstallConfiguration(String instanceName) throws IOException;
/**
* Prompt the user asking them if they are sure they would like to do the
@@ -63,14 +65,13 @@ public interface InstallPrompt {
@Override
public String promptInstanceName() throws IOException {
- final ConsoleReader reader = getReader();
- reader.setPrompt("Rya Instance Name: ");
- final String instanceName = reader.readLine();
+ final String prompt = makeFieldPrompt("Rya Instance Name", "rya_");
+ final String instanceName = promptString(prompt, Optional.of("rya_"));
return instanceName;
}
@Override
- public InstallConfiguration promptInstallConfiguration() throws IOException {
+ public InstallConfiguration promptInstallConfiguration(final String instanceName) throws IOException {
final InstallConfiguration.Builder builder = InstallConfiguration.builder();
String prompt = makeFieldPrompt("Use Shard Balancing (improves streamed input write speeds)", false);
@@ -89,24 +90,24 @@ public interface InstallPrompt {
final boolean enableGeoIndexing = promptBoolean(prompt, Optional.of(true));
builder.setEnableGeoIndex( enableGeoIndexing );
+ prompt = makeFieldPrompt("Use Temporal Indexing", true);
+ final boolean useTemporalIndexing = promptBoolean(prompt, Optional.of(true));
+ builder.setEnableTemporalIndex( useTemporalIndexing );
+
prompt = makeFieldPrompt("Use Precomputed Join Indexing", true);
final boolean enablePCJIndexing = promptBoolean(prompt, Optional.of(true));
builder.setEnablePcjIndex( enablePCJIndexing );
if(enablePCJIndexing) {
- final boolean useFluoApp = promptBoolean("Use a Fluo application to update the PCJ? ", Optional.absent());
+ final boolean useFluoApp = promptBoolean("Use a Fluo application to update the PCJ Index? (y/n) ", Optional.absent());
if(useFluoApp) {
- prompt = "PCJ Updater Fluo Application Name: ";
- final String fluoAppName = promptString(prompt, Optional.<String>absent());
+ prompt = makeFieldPrompt("PCJ Updater Fluo Application Name (must be initialized)", instanceName + "pcj_updater");
+ final String fluoAppName = promptString(prompt, Optional.of(instanceName + "pcj_updater"));
builder.setFluoPcjAppName(fluoAppName);
}
}
- prompt = makeFieldPrompt("Use Temporal Indexing", true);
- final boolean useTemporalIndexing = promptBoolean(prompt, Optional.of(true));
- builder.setEnableTemporalIndex( useTemporalIndexing );
-
return builder.build();
}
@@ -120,7 +121,7 @@ public interface InstallPrompt {
reader.println(" Use Entity Centric Indexing: " + installConfig.isEntityCentrixIndexEnabled());
reader.println(" Use Free Text Indexing: " + installConfig.isFreeTextIndexEnabled());
reader.println(" Use Geospatial Indexing: " + installConfig.isGeoIndexEnabled());
-
+ reader.println(" Use Temporal Indexing: " + installConfig.isTemporalIndexEnabled());
reader.println(" Use Precomputed Join Indexing: " + installConfig.isPcjIndexEnabled());
if(installConfig.isPcjIndexEnabled()) {
if(installConfig.getFluoPcjAppName().isPresent()) {
@@ -130,10 +131,9 @@ public interface InstallPrompt {
}
}
- reader.println(" Use Temporal Indexing: " + installConfig.isTemporalIndexEnabled());
reader.println("");
- return promptBoolean("Continue with the install? ", Optional.<Boolean>absent());
+ return promptBoolean("Continue with the install? (y/n) ", Optional.absent());
}
}
}
\ No newline at end of file