RYA-125 Export tool API in RYA (#10) This contains the interfaces and api for the new export tool.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/24c71838 Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/24c71838 Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/24c71838 Branch: refs/heads/master Commit: 24c718380194d2f0a3f3968e6ff8a9923a2ef616 Parents: 8484bbc Author: Andrew Smith <[email protected]> Authored: Thu Sep 1 16:03:31 2016 -0400 Committer: isper3at <[email protected]> Committed: Wed Nov 2 17:51:18 2016 -0400 ---------------------------------------------------------------------- extras/rya.export/export.api/pom.xml | 333 +++++++++++++ extras/rya.export/export.api/src/gen/.gitignore | 1 + .../java/org/apache/rya/export/api/Merger.java | 34 ++ .../apache/rya/export/api/MergerException.java | 58 +++ .../apache/rya/export/api/StatementMerger.java | 37 ++ .../export/api/conf/ConfigurationAdapter.java | 46 ++ .../rya/export/api/conf/MergeConfiguration.java | 464 +++++++++++++++++++ .../api/conf/MergeConfigurationException.java | 34 ++ .../export/api/parent/MergeParentMetadata.java | 137 ++++++ .../ParentMetadataDoesNotExistException.java | 35 ++ .../api/parent/ParentMetadataException.java | 35 ++ .../parent/ParentMetadataExistsException.java | 35 ++ .../api/parent/ParentMetadataRepository.java | 43 ++ .../export/api/store/AddStatementException.java | 46 ++ .../api/store/ContainsStatementException.java | 47 ++ .../api/store/FetchStatementException.java | 46 ++ .../api/store/RemoveStatementException.java | 46 ++ .../rya/export/api/store/RyaStatementStore.java | 74 +++ .../api/store/RyaStatementStoreDecorator.java | 67 +++ .../api/store/StatementStoreException.java | 45 ++ .../api/store/UpdateStatementException.java | 47 ++ .../src/main/xsd/MergeConfiguration.xsd | 80 ++++ extras/rya.export/pom.xml | 3 +- 23 files changed, 1792 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/pom.xml ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/pom.xml b/extras/rya.export/export.api/pom.xml new file mode 100644 index 0000000..d0f88ee --- /dev/null +++ b/extras/rya.export/export.api/pom.xml @@ -0,0 +1,333 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> +<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"> + + <parent> + <groupId>org.apache.rya</groupId> + <artifactId>rya.export.parent</artifactId> + <version>3.2.10-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>rya.export.api</artifactId> + + <name>Apache Rya Export API</name> + <description> + This module contains the Rya Export API. It consists of classes + that allow other applications to import and export statements. + </description> + + <dependencies> + <!-- Rya Runtime Dependencies. --> + <dependency> + <groupId>org.apache.rya</groupId> + <artifactId>rya.sail</artifactId> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + <version>3.2</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.2</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.rya</groupId> + <artifactId>mongodb.rya</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.4.3</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.3</version> + </dependency> + <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-xjc</artifactId> + <version>2.2.11</version> + </dependency> + </dependencies> + + <build> + <pluginManagement> + <plugins> + <!-- + If we e.g. execute on JDK 1.7, we should compile for Java 7 to get + the same (or higher) JAXB API version as used during the xjc execution. + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </pluginManagement> + + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.0.2</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <version>2.19.1</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxb2-maven-plugin</artifactId> + <version>2.2</version> + <executions> + <execution> + <id>xjc</id> + <goals> + <goal>xjc</goal> + </goals> + </execution> + </executions> + <configuration> + <sources> + <source>src/main/xsd/MergeConfiguration.xsd</source> + </sources> + <packageName>org.apache.rya.export</packageName> + <outputDirectory>src/gen/java</outputDirectory> + </configuration> + </plugin> + + <!-- + Create shaded jar with all the dependencies + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.4.3</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <manifestEntries> + <!--<Main-Class>mvm.rya.accumulo.mr.merge.MergeTool</Main-Class>--> + </manifestEntries> + </transformer> + </transformers> + <artifactSet> + <excludes> + <exclude>org.apache.accumulo:accumulo-native</exclude> + </excludes> + </artifactSet> + <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> + + <!-- + Creates the lib directory with all the dependencies + --> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <phase>install</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/lib</outputDirectory> + <overWriteReleases>false</overWriteReleases> + <overWriteSnapshots>false</overWriteSnapshots> + <overWriteIfNewer>true</overWriteIfNewer> + </configuration> + </execution> + </executions> + </plugin> + + <!-- + Creates the rya.merger-*.jar + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>lib</classpathPrefix> + <!--Removing main-class from manifest so hadoop command will be able to call multiple main classes--> + <!--<mainClass>mvm.rya.accumulo.mr.merge.MergeTool</mainClass>--> + </manifest> + <manifestEntries> + <Built-By></Built-By> + <Class-Path>lib/</Class-Path> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <!-- + Copies all needed files into target/distribution/rya.merger-${version} + --> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>2.7</version> + <executions> + <execution> + <id>copy-resource-bin</id> + <phase>install</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/distribution/${artifactId}-${version}/bin</outputDirectory> + <resources> + <resource> + <directory>${basedir}/startup_scripts</directory> + </resource> + </resources> + </configuration> + </execution> + <execution> + <id>copy-resource-config</id> + <phase>install</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/distribution/${artifactId}-${version}/config</outputDirectory> + <resources> + <resource> + <directory>${basedir}/config</directory> + </resource> + </resources> + </configuration> + </execution> + <execution> + <id>copy-resource-lib</id> + <phase>install</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/distribution/${artifactId}-${version}/lib</outputDirectory> + <resources> + <resource> + <directory>${project.build.directory}/lib</directory> + <includes> + <include>*.jar</include> + </includes> + </resource> + </resources> + </configuration> + </execution> + <execution> + <id>copy-resource-jar</id> + <phase>install</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/distribution/${artifactId}-${version}/</outputDirectory> + <resources> + <resource> + <directory>${project.build.directory}</directory> + <includes> + <include>rya.merger-*.jar</include> + <include>README.md</include> + </includes> + <excludes> + <exclude>rya.merger-*-shaded.jar</exclude> + <exclude>rya.merger-*-sources.jar</exclude> + </excludes> + </resource> + </resources> + </configuration> + </execution> + <execution> + <id>copy-resource-readme</id> + <phase>install</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/distribution/${artifactId}-${version}/</outputDirectory> + <resources> + <resource> + <directory>${basedir}</directory> + <includes> + <include>README.md</include> + </includes> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/gen/.gitignore ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/gen/.gitignore b/extras/rya.export/export.api/src/gen/.gitignore new file mode 100644 index 0000000..1e574a9 --- /dev/null +++ b/extras/rya.export/export.api/src/gen/.gitignore @@ -0,0 +1 @@ +/java/ http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/Merger.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/Merger.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/Merger.java new file mode 100644 index 0000000..ce3e9d7 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/Merger.java @@ -0,0 +1,34 @@ +/* + * 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.export.api; + +import mvm.rya.api.domain.RyaStatement; + +/** + * Performs the merging of {@link RyaStatement}s. + * <p> + * When merging statements, both the parent and child + * databases may have changed since the initial export. + */ +public interface Merger { + /** + * Performs the merging of {@link RyaStatement}s. + */ + public void runJob(); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/MergerException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/MergerException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/MergerException.java new file mode 100644 index 0000000..8b1c80d --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/MergerException.java @@ -0,0 +1,58 @@ +/* + * 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.export.api; + +/** + * An exception to be used when there is a problem running the Merge Tool. + */ +public class MergerException extends Exception { + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance of {@link MergerException}. + */ + public MergerException() { + super(); + } + + /** + * Creates a new instance of {@link MergerException}. + * @param message the detail message. + */ + public MergerException(final String message) { + super(message); + } + + /** + * Creates a new instance of {@link MergerException}. + * @param message the detail message. + * @param throwable the {@link Throwable} source. + */ + public MergerException(final String message, final Throwable source) { + super(message, source); + } + + /** + * Creates a new instance of {@link MergerException}. + * @param source the {@link Throwable} source. + */ + public MergerException(final Throwable source) { + super(source); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/StatementMerger.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/StatementMerger.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/StatementMerger.java new file mode 100644 index 0000000..2737752 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/StatementMerger.java @@ -0,0 +1,37 @@ +/* + * 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.export.api; + +import com.google.common.base.Optional; + +import mvm.rya.api.domain.RyaStatement; + +/** + * Defines how 2 {@link RyaStatement}s will merge. + */ +public interface StatementMerger { + /** + * Merges the child statement into the parent statement. + * @param parent - The parent {@link RyaStatement}. + * @param child - The child {@link RyaStatement} + * @return The merged {@link RyaStatement}. + * @throws MergerException + */ + public Optional<RyaStatement> merge(final Optional<RyaStatement> parent, Optional<RyaStatement> child) throws MergerException; +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/ConfigurationAdapter.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/ConfigurationAdapter.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/ConfigurationAdapter.java new file mode 100644 index 0000000..39c4e0b --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/ConfigurationAdapter.java @@ -0,0 +1,46 @@ +/* + * 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.export.api.conf; + +import org.apache.rya.export.JAXBMergeConfiguration; +import org.apache.rya.export.api.conf.MergeConfiguration.Builder; + +/** + * Helper for creating the immutable application configuration. + */ +public class ConfigurationAdapter { + /** + * @param jConfig - The JAXB generated configuration. + * @return The {@link MergeConfiguration} used in the application + * @throws MergeConfigurationException + */ + public static MergeConfiguration createConfig(final JAXBMergeConfiguration jConfig) throws MergeConfigurationException { + final Builder configBuilder = new Builder() + .setParentHostname(jConfig.getParentHostname()) + .setParentRyaInstanceName(jConfig.getParentRyaInstanceName()) + .setParentDBType(jConfig.getParentDBType()) + .setParentPort(jConfig.getParentPort()) + .setChildHostname(jConfig.getChildHostname()) + .setChildRyaInstanceName(jConfig.getChildRyaInstanceName()) + .setChildDBType(jConfig.getChildDBType()) + .setChildPort(jConfig.getChildPort()) + .setMergePolicy(jConfig.getMergePolicy()); + return configBuilder.build(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/MergeConfiguration.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/MergeConfiguration.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/MergeConfiguration.java new file mode 100644 index 0000000..dd6fd89 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/MergeConfiguration.java @@ -0,0 +1,464 @@ +/* + * 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.export.api.conf; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.apache.http.annotation.Immutable; +import org.apache.rya.export.DBType; +import org.apache.rya.export.MergePolicy; + +/** + * Immutable configuration object to allow the MergeTool to connect to the parent and child + * databases for data merging. + */ +@Immutable +public class MergeConfiguration { + /** + * Information needed to connect to the parent database + */ + private final String parentHostname; + private final String parentUsername; + private final String parentPassword; + private final String parentRyaInstanceName; + private final String parentTablePrefix; + private final String parentTomcatUrl; + private final DBType parentDBType; + private final int parentPort; + + /** + * Information needed to connect to the child database + */ + private final String childHostname; + private final String childUsername; + private final String childPassword; + private final String childRyaInstanceName; + private final String childTablePrefix; + private final String childTomcatUrl; + private final DBType childDBType; + private final int childPort; + + private final MergePolicy mergePolicy; + + private final boolean useNtpServer; + private final String ntpServerHost; + private final String toolStartTime; + + /** + * Constructs a {@link MergeConfiguration}. + */ + protected MergeConfiguration(final Builder builder) throws MergeConfigurationException { + try { + parentHostname = checkNotNull(builder.parentHostname); + parentUsername = checkNotNull(builder.parentUsername); + parentPassword = checkNotNull(builder.parentPassword); + parentRyaInstanceName = checkNotNull(builder.parentRyaInstanceName); + parentTablePrefix = checkNotNull(builder.parentTablePrefix); + parentTomcatUrl = checkNotNull(builder.parentTomcatUrl); + parentDBType = checkNotNull(builder.parentDBType); + parentPort = checkNotNull(builder.parentPort); + childHostname = checkNotNull(builder.childHostname); + childUsername = checkNotNull(builder.childUsername); + childPassword = checkNotNull(builder.childPassword); + childRyaInstanceName = checkNotNull(builder.childRyaInstanceName); + childTablePrefix = checkNotNull(builder.childTablePrefix); + childTomcatUrl = checkNotNull(builder.childTomcatUrl); + childDBType = checkNotNull(builder.childDBType); + childPort = checkNotNull(builder.childPort); + mergePolicy = checkNotNull(builder.mergePolicy); + useNtpServer = checkNotNull(builder.useNtpServer); + ntpServerHost = checkNotNull(builder.ntpServerHost); + toolStartTime = checkNotNull(builder.toolStartTime); + } catch(final NullPointerException npe) { + //fix this. + throw new MergeConfigurationException("The configuration was missing required field(s)", npe); + } + } + + /** + * @return the hostname of the parent. + */ + public String getParentHostname() { + return parentHostname; + } + + /** + * @return the username of the parent. + */ + public String getParentUsername() { + return parentUsername; + } + + /** + * @return the password of the parent. + */ + public String getParentPassword() { + return parentPassword; + } + + /** + * @return the Rya Instance Name of the parent. + */ + public String getParentRyaInstanceName() { + return parentRyaInstanceName; + } + + /** + * @return the Rya table prefix of the parent. + */ + public String getParentTablePrefix() { + return parentTablePrefix; + } + + /** + * @return The URL of the Apache Tomcat server web page running on the parent machine. + */ + public String getParentTomcatUrl() { + return parentTomcatUrl; + } + + /** + * @return the Database Type of the parent. + */ + public DBType getParentDBType() { + return parentDBType; + } + + /** + * @return the port of the parent. + */ + public int getParentPort() { + return parentPort; + } + + /** + * @return the hostname of the child. + */ + public String getChildHostname() { + return childHostname; + } + + /** + * @return the username of the child. + */ + public String getChildUsername() { + return childUsername; + } + + /** + * @return the password of the child. + */ + public String getChildPassword() { + return childPassword; + } + + /** + * @return the Rya Instance Name of the child. + */ + public String getChildRyaInstanceName() { + return childRyaInstanceName; + } + + /** + * @return the Rya table prefix of the child. + */ + public String getChildTablePrefix() { + return childTablePrefix; + } + + /** + * @return The URL of the Apache Tomcat server web page running on the child machine. + */ + public String getChildTomcatUrl() { + return childTomcatUrl; + } + + /** + * @return the Database Type of the child. + */ + public DBType getChildDBType() { + return childDBType; + } + + /** + * @return the port of the child. + */ + public int getChildPort() { + return childPort; + } + + /** + * @return the policy to use when merging data. + */ + public MergePolicy getMergePolicy() { + return mergePolicy; + } + + /** + * @return {@code true} to use the NTP server to handle time synchronization. + * {@code false} to not use the NTP server. + */ + public Boolean getUseNtpServer() { + return useNtpServer; + } + + /** + * @return The host name of the time server to use. + */ + public String getNtpServerHost() { + return ntpServerHost; + } + + /** + * @return The time of the data to be included in the copy/merge process. + */ + public String getToolStartTime() { + return toolStartTime; + } + + /** + * Abstract builder to help create {@link MergeConfiguration}s. + */ + public abstract static class AbstractBuilder<T extends AbstractBuilder<T>> { + /** + * @return The {@link MergeConfiguration} based on this builder. + * @throws MergeConfigurationException + * @throws NullPointerException if any field as not been provided + */ + public abstract MergeConfiguration build() throws MergeConfigurationException; + } + + /** + * Builder to help create {@link MergeConfiguration}s. + */ + public static class Builder extends AbstractBuilder<Builder> { + private String parentHostname; + private String parentUsername; + private String parentPassword; + private String parentRyaInstanceName; + private String parentTablePrefix; + private String parentTomcatUrl; + private DBType parentDBType; + private Integer parentPort; + + private String childHostname; + private String childUsername; + private String childPassword; + private String childRyaInstanceName; + private String childTablePrefix; + private String childTomcatUrl; + private DBType childDBType; + private Integer childPort; + + private MergePolicy mergePolicy; + + private Boolean useNtpServer; + private String ntpServerHost; + private String toolStartTime; + + /** + * @param hostname - the hostname of the parent. + * @return the updated {@link Builder}. + */ + public Builder setParentHostname(final String hostname) { + parentHostname = hostname; + return this; + } + + /** + * @param username - the username of the parent. + * @return the updated {@link Builder}. + */ + public Builder setParentUsername(final String username) { + parentUsername = username; + return this; + } + + /** + * @param password - the password of the parent. + * @return the updated {@link Builder}. + */ + public Builder setParentPassword(final String password) { + parentPassword = password; + return this; + } + + /** + * @param ryaInstanceName - the Rya Instance Name of the parent. + * @return the updated {@link Builder}. + */ + public Builder setParentRyaInstanceName(final String ryaInstanceName) { + parentRyaInstanceName = ryaInstanceName; + return this; + } + + /** + * @param tablePrefix - the Rya table prefix of the parent. + * @return the updated {@link Builder}. + */ + public Builder setParentTablePrefix(final String tablePrefix) { + parentTablePrefix = tablePrefix; + return this; + } + + /** + * @param tomcatUrl - The URL of the Apache Tomcat server web page + * running on the parent machine. + * @return the updated {@link Builder}. + */ + public Builder setParentTomcatUrl(final String tomcatUrl) { + parentTomcatUrl = tomcatUrl; + return this; + } + + /** + * @param dbType - the Database Type of the parent. + * @return the updated {@link Builder}. + */ + public Builder setParentDBType(final DBType dbType) { + parentDBType = dbType; + return this; + } + + /** + * @param port - the port of the parent. + * @return the updated {@link Builder}. + */ + public Builder setParentPort(final Integer port) { + parentPort = port; + return this; + } + + /** + * @param hostname - the hostname of the child. + * @return the updated {@link Builder}. + */ + public Builder setChildHostname(final String hostname) { + childHostname = hostname; + return this; + } + + /** + * @param username - the username of the child. + * @return the updated {@link Builder}. + */ + public Builder setChildUsername(final String username) { + childUsername = username; + return this; + } + + /** + * @param password - the password of the child. + * @return the updated {@link Builder}. + */ + public Builder setChildPassword(final String password) { + childPassword = password; + return this; + } + + /** + * @param ryaInstanceName - the Rya Instance Name of the child. + * @return the updated {@link Builder}. + */ + public Builder setChildRyaInstanceName(final String ryaInstanceName) { + childRyaInstanceName = ryaInstanceName; + return this; + } + + /** + * @param tablePrefix - the Rya table prefix of the child. + * @return the updated {@link Builder}. + */ + public Builder setChildTablePrefix(final String tablePrefix) { + childTablePrefix = tablePrefix; + return this; + } + + /** + * @param tomcatUrl -s The URL of the Apache Tomcat server web page + * running on the child machine. + * @return the updated {@link Builder}. + */ + public Builder setChildTomcatUrl(final String tomcatUrl) { + childTomcatUrl = tomcatUrl; + return this; + } + + /** + * @param dbType - the Database Type of the child. + * @return the updated {@link Builder}. + */ + public Builder setChildDBType(final DBType dbType) { + childDBType = dbType; + return this; + } + + /** + * @param port - the port of the child. + * @return the updated {@link Builder}. + */ + public Builder setChildPort(final Integer port) { + childPort = port; + return this; + } + + /** + * @param mergePolicy - the policy to use when merging data. + * @return the updated {@link Builder}. + */ + public Builder setMergePolicy(final MergePolicy mergePolicy) { + this.mergePolicy = mergePolicy; + return this; + } + + /** + * @param useNtpServer - {@code true} to use the NTP server to handle + * time synchronization. {@code false} to not use the NTP server. + * @return the updated {@link Builder}. + */ + public Builder setUseNtpServer(final Boolean useNtpServer) { + this.useNtpServer = useNtpServer; + return this; + } + + /** + * @param ntpServerHost - The host name of the time server to use. + * @return the updated {@link Builder}. + */ + public Builder setNtpServerHost(final String ntpServerHost) { + this.ntpServerHost = ntpServerHost; + return this; + } + + /** + * @param toolStartTime - The time of the data to be included in the + * copy/merge process. + * @return the updated {@link Builder}. + */ + public Builder setToolStartTime(final String toolStartTime) { + this.toolStartTime = toolStartTime; + return this; + } + + @Override + public MergeConfiguration build() throws MergeConfigurationException { + return new MergeConfiguration(this); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/MergeConfigurationException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/MergeConfigurationException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/MergeConfigurationException.java new file mode 100644 index 0000000..7e099e1 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/conf/MergeConfigurationException.java @@ -0,0 +1,34 @@ +/* + * 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.export.api.conf; + +/** + * An exception to be used when there is a problem configuring the Merge Tool. + */ +public class MergeConfigurationException extends Exception { + private static final long serialVersionUID = 1L; + + public MergeConfigurationException(final String message) { + super(message); + } + + public MergeConfigurationException(final String message, final Throwable source) { + super(message, source); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/MergeParentMetadata.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/MergeParentMetadata.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/MergeParentMetadata.java new file mode 100644 index 0000000..2401adf --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/MergeParentMetadata.java @@ -0,0 +1,137 @@ +/* + * 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.export.api.parent; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Date; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +/** + * The parent database identifying information. Use the {@link ParentMetadataRepository} + * to retrieve this information + */ +public class MergeParentMetadata { + private final String ryaInstanceName; + private final Date timestamp; + private final Date filterTimestamp; + private final Long parentTimeOffset; + + /** + * Creates a new {@link MergeParentMetadata}. + * @param ryaInstanceName - The Rya Instance Name of the parent database. + * @param timestamp - The timestamp of when the copy tool ran. + * @param filterTimestamp - The timestamp used by the copy tool to filter + * which data was included when copying. + * @param parentTimeOffset - The parent time offset metadata key for the + * table. + */ + public MergeParentMetadata(final String ryaInstanceName, final Date timestamp, final Date filterTimestamp, final Long parentTimeOffset) { + this.ryaInstanceName = checkNotNull(ryaInstanceName); + this.timestamp = checkNotNull(timestamp); + this.filterTimestamp = filterTimestamp; + this.parentTimeOffset = checkNotNull(parentTimeOffset); + } + + /** + * @return - The Rya Instance Name of the parent database. + */ + public String getRyaInstanceName() { + return ryaInstanceName; + } + + /** + * @return - The timestamp of when the copy tool ran. + */ + public Date getTimestamp() { + return timestamp; + } + + /** + * @return - The timestamp used by the copy tool to filter which data was + * included when copying. + */ + public Date getFilterTimestamp() { + return filterTimestamp; + } + + /** + * @return - The parent time offset metadata key for the table. + */ + public Long getParentTimeOffset() { + return parentTimeOffset; + } + + @Override + public boolean equals(final Object obj) { + if(!(obj instanceof MergeParentMetadata)) { + return false; + } + final MergeParentMetadata other = (MergeParentMetadata) obj; + final EqualsBuilder builder = new EqualsBuilder() + .append(getRyaInstanceName(), other.getRyaInstanceName()) + .append(getTimestamp(), other.getTimestamp()) + .append(getFilterTimestamp(), other.getFilterTimestamp()) + .append(getParentTimeOffset(), other.getParentTimeOffset()); + return builder.isEquals(); + } + + @Override + public int hashCode() { + final HashCodeBuilder builder = new HashCodeBuilder() + .append(getRyaInstanceName()) + .append(getTimestamp()) + .append(getFilterTimestamp()) + .append(getParentTimeOffset()); + return builder.toHashCode(); + } + + public static class Builder { + private String name; + private Date timestamp; + private Date filterTimestamp; + private Long parentTimeOffset; + + public Builder setRyaInstanceName(final String name) { + this.name = checkNotNull(name); + return this; + } + + public Builder setTimestamp(final Date timestamp) { + this.timestamp = checkNotNull(timestamp); + return this; + } + + public Builder setFilterTimestmap(final Date filterTimestamp) { + this.filterTimestamp = checkNotNull(filterTimestamp); + return this; + } + + public Builder setParentTimeOffset(final Long parentTimeOffset) { + this.parentTimeOffset = parentTimeOffset; + return this; + } + + public MergeParentMetadata build() { + return new MergeParentMetadata(name, timestamp, filterTimestamp, parentTimeOffset); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataDoesNotExistException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataDoesNotExistException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataDoesNotExistException.java new file mode 100644 index 0000000..f6f691c --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataDoesNotExistException.java @@ -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. + */ +package org.apache.rya.export.api.parent; + +/** + * Thrown when the {@link ParentMetadataRepository} attempts to fetch + * the {@link MergeParentMetadata} and it does not exist. / + */ +public class ParentMetadataDoesNotExistException extends ParentMetadataException { + private static final long serialVersionUID = 1L; + + public ParentMetadataDoesNotExistException(final String message) { + super(message); + } + + public ParentMetadataDoesNotExistException(final String message, final Throwable cause) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataException.java new file mode 100644 index 0000000..e3645b7 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataException.java @@ -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. + */ +package org.apache.rya.export.api.parent; + +/** + * Thrown when the {@link ParentMetadataRepository} attempts to fetch + * the {@link MergeParentMetadata} and it does not exist. + */ +class ParentMetadataException extends Exception { + private static final long serialVersionUID = 1L; + + public ParentMetadataException(final String message) { + super(message); + } + + public ParentMetadataException(final String message, final Throwable cause) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataExistsException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataExistsException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataExistsException.java new file mode 100644 index 0000000..6ff63dc --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataExistsException.java @@ -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. + */ +package org.apache.rya.export.api.parent; + +/** + * Thrown when the {@link ParentMetadataRepository} attempts to set the + * {@link MergeParentMetadata} and it already exists. + */ +public class ParentMetadataExistsException extends ParentMetadataException { + private static final long serialVersionUID = 1L; + + public ParentMetadataExistsException(final String message) { + super(message); + } + + public ParentMetadataExistsException(final String message, final Throwable cause) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataRepository.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataRepository.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataRepository.java new file mode 100644 index 0000000..c5ab665 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/parent/ParentMetadataRepository.java @@ -0,0 +1,43 @@ +/* + * 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.export.api.parent; + +/** + * Repository for metadata pertaining to the parent database. This will contain + * all information to identify where any data was exported from. + * <p> + * The data found here is: + * <li>Parent database Rya Instance Name</li> + * <li>Timestamp used as the lower cutoff for the export</li> + */ +public interface ParentMetadataRepository { + /** + * @return The metadata for identifying the parent. + * @throws ParentMetadataDoesNotExistException - The {@link MergeParentMetadata} + * has not been set. + */ + public MergeParentMetadata get() throws ParentMetadataDoesNotExistException; + + /** + * @param metadata - The identifying metadata for the parent. + * @throws ParentMetadataExistsException - The {@link MergeParentMetadata} has + * already been set. + */ + public void set(MergeParentMetadata metadata) throws ParentMetadataExistsException; +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/AddStatementException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/AddStatementException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/AddStatementException.java new file mode 100644 index 0000000..48cf7d4 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/AddStatementException.java @@ -0,0 +1,46 @@ +/* + * 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.export.api.store; + +import mvm.rya.api.domain.RyaStatement; + +/** + * Exception thrown when failing to add a {@link RyaStatement} to a + * {@link RyaStatementStore}. + */ +public class AddStatementException extends StatementStoreException { + private static final long serialVersionUID = 1L; + + /** + * Creates a new {@link AddStatementException} with a message. + * @param message - The error message. + */ + public AddStatementException(final String message) { + super(message); + } + + /** + * Creates a new {@link AddStatementException} with a message and cause. + * @param message - The error message. + * @param cause - The cause of this exception + */ + public AddStatementException(final String message, final Throwable cause) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/ContainsStatementException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/ContainsStatementException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/ContainsStatementException.java new file mode 100644 index 0000000..c091e90 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/ContainsStatementException.java @@ -0,0 +1,47 @@ +/* + * 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.export.api.store; + +import mvm.rya.api.domain.RyaStatement; + +/** + * Exception thrown when failing to check a {@link RyaStatementStore} for a + * {@link RyaStatement}. + */ +public class ContainsStatementException extends StatementStoreException { + private static final long serialVersionUID = 1L; + + /** + * Creates a new {@link ContainsStatementException} with a message. + * @param message - The error message. + */ + public ContainsStatementException(final String message) { + super(message); + } + + /** + * Creates a new {@link ContainsStatementException} with a message and cause. + * @param message - The error message. + * @param cause - The cause of this exception + */ + public ContainsStatementException(final String message, final Throwable cause) { + super(message, cause); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/FetchStatementException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/FetchStatementException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/FetchStatementException.java new file mode 100644 index 0000000..fe06d58 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/FetchStatementException.java @@ -0,0 +1,46 @@ +/* + * 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.export.api.store; + +import mvm.rya.api.domain.RyaStatement; + +/** + * Exception thrown when failing to fetch a {@link RyaStatement} from a + * {@link RyaStatementStore}. + */ +public class FetchStatementException extends StatementStoreException { + private static final long serialVersionUID = 1L; + + /** + * Creates a new {@link FetchStatementException} with a message. + * @param message - The error message. + */ + public FetchStatementException(final String message) { + super(message); + } + + /** + * Creates a new {@link FetchStatementException} with a message and cause. + * @param message - The error message. + * @param cause - The cause of this exception + */ + public FetchStatementException(final String message, final Throwable cause) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RemoveStatementException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RemoveStatementException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RemoveStatementException.java new file mode 100644 index 0000000..7d45348 --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RemoveStatementException.java @@ -0,0 +1,46 @@ +/* + * 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.export.api.store; + +import mvm.rya.api.domain.RyaStatement; + +/** + * Exception thrown when failing to remove a {@link RyaStatement} from a + * {@link RyaStatementStore}. + */ +public class RemoveStatementException extends StatementStoreException { + private static final long serialVersionUID = 1L; + + /** + * Creates a new {@link FetchStatementException} with a message. + * @param message - The error message. + */ + public RemoveStatementException(final String message) { + super(message); + } + + /** + * Creates a new {@link RemoveStatementException} with a message and cause. + * @param message - The error message. + * @param cause - The cause of this exception + */ + public RemoveStatementException(final String message, final Throwable cause) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RyaStatementStore.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RyaStatementStore.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RyaStatementStore.java new file mode 100644 index 0000000..3f4e6fb --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RyaStatementStore.java @@ -0,0 +1,74 @@ +/* + * 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.export.api.store; + +import java.util.Iterator; + +import mvm.rya.api.domain.RyaStatement; + +/** + * Allows specific CRUD operations on {@link RyaStatement} storage systems. + * <p> + * The operations specifically: + * <li>fetch all rya statements in the store</li> + * <li>add a rya statement to the store</li> + * <li>remove a rya statement from the store</li> + * <li>update an existing rya statement with a new one</li> + * + * One would use this {@link RyaStatementStore} when they have a database or + * some storage system that is used when merging in data or exporting data. + */ +public interface RyaStatementStore { + /** + * @return an {@link Iterator} containing all {@link RyaStatement}s found + * in this {@link RyaStatementStore}. The statements will be sorted by + * timestamp. + * @throws FetchStatementException - Thrown when fetching a statement fails. + */ + public Iterator<RyaStatement> fetchStatements() throws FetchStatementException; + + /** + * @param statement - The {@link RyaStatement} to add to this {@link RyaStatementStore}. + * @throws AddStatementException Thrown when adding a statement fails. + */ + public void addStatement(final RyaStatement statement) throws AddStatementException; + + /** + * @param statement - The {@link RyaStatement} to remove from this {@link RyaStatementStore}. + * @throws RemoveStatementException - Thrown when the statement is not removed + */ + public void removeStatement(final RyaStatement statement) throws RemoveStatementException; + + /** + * Updates the original {@link RyaStatement} with a new one. + * @param original - The {@link RyaStatement} to update. + * @param update - The new {@link RyaStatement} to replace the original one. + * @throws UpdateStatementException - Thrown when updating a statement fails. + */ + public void updateStatement(final RyaStatement original, final RyaStatement update) throws UpdateStatementException; + + /** + * Queries to see if the statement is contained in the statement store. + * @param ryaStatement the {@link RyaStatement} to search for. + * @return {@code true} if the statement store contains the statement. + * {@code false} otherwise. + * @throws ContainsStatementException - Thrown when an exception occurs trying to check for the statement. + */ + public boolean containsStatement(final RyaStatement ryaStatement) throws ContainsStatementException; +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RyaStatementStoreDecorator.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RyaStatementStoreDecorator.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RyaStatementStoreDecorator.java new file mode 100644 index 0000000..3a5794b --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/RyaStatementStoreDecorator.java @@ -0,0 +1,67 @@ +/* + * 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.export.api.store; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Iterator; + +import mvm.rya.api.domain.RyaStatement; + +/** + * Decorates a {@link RyaStatementStore}. This is to be used when the default + * actions for {@link RyaStatement}s in the {@link RyaStatementStore} need to + * do something more specific. + */ +public abstract class RyaStatementStoreDecorator implements RyaStatementStore { + final RyaStatementStore store; + + /** + * Creates a new {@link RyaStatementStoreDecorator} around the provided {@link RyaStatementStore}. + * @param store - The {@link RyaStatementStore} to decorate. + */ + public RyaStatementStoreDecorator(final RyaStatementStore store) { + this.store = checkNotNull(store); + } + + @Override + public Iterator<RyaStatement> fetchStatements() throws FetchStatementException { + return store.fetchStatements(); + } + + @Override + public void addStatement(final RyaStatement statement) throws AddStatementException { + store.addStatement(statement); + } + + @Override + public void removeStatement(final RyaStatement statement) throws RemoveStatementException { + store.removeStatement(statement); + } + + @Override + public void updateStatement(final RyaStatement original, final RyaStatement update) throws UpdateStatementException { + store.updateStatement(original, update); + } + + @Override + public boolean containsStatement(final RyaStatement statement) throws ContainsStatementException { + return store.containsStatement(statement); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/StatementStoreException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/StatementStoreException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/StatementStoreException.java new file mode 100644 index 0000000..202a49f --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/StatementStoreException.java @@ -0,0 +1,45 @@ +/* + * 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.export.api.store; + +import org.apache.rya.export.api.MergerException; + +/** + * Thrown when an exception occurs in the {@link RyaStatementStore}. + */ +class StatementStoreException extends MergerException { + private static final long serialVersionUID = 1L; + + /** + * Creates a new {@link StatementStoreException} with a message. + * @param message The error message. + */ + public StatementStoreException(final String message) { + super(message); + } + + /** + * Creates a new {@link StatementStoreException} with a message and cause. + * @param message The error message. + * @param cause The cause of this exception. + */ + public StatementStoreException(final String message, final Throwable cause) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/UpdateStatementException.java ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/UpdateStatementException.java b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/UpdateStatementException.java new file mode 100644 index 0000000..26f776b --- /dev/null +++ b/extras/rya.export/export.api/src/main/java/org/apache/rya/export/api/store/UpdateStatementException.java @@ -0,0 +1,47 @@ +/* + * 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.export.api.store; + +import mvm.rya.api.domain.RyaStatement; + +/** + * Exception thrown when failing to update a {@link RyaStatement} in a + * {@link RyaStatementStore}. + */ +public class UpdateStatementException extends StatementStoreException { + private static final long serialVersionUID = 1L; + + /** + * Creates a new {@link UpdateStatementException} with a message. + * @param message - The error message. + */ + public UpdateStatementException(final String message) { + super(message); + } + + /** + * Creates a new {@link UpdateStatementException} with a message and cause. + * @param message - The error message. + * @param cause - The cause of this exception + */ + public UpdateStatementException(final String message, final Throwable cause) { + super(message, cause); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/export.api/src/main/xsd/MergeConfiguration.xsd ---------------------------------------------------------------------- diff --git a/extras/rya.export/export.api/src/main/xsd/MergeConfiguration.xsd b/extras/rya.export/export.api/src/main/xsd/MergeConfiguration.xsd new file mode 100644 index 0000000..036b067 --- /dev/null +++ b/extras/rya.export/export.api/src/main/xsd/MergeConfiguration.xsd @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:mc="http://mergeconfig" + targetNamespace="http://mergeconfig" + elementFormDefault="qualified"> + + <xs:element name="configuration" type="mc:JAXBMergeConfiguration"/> + + <xs:complexType name="JAXBMergeConfiguration"> + <xs:sequence> + <xs:element name="parentHostname" type="xs:string"/> + <xs:element name="parentUsername" type="xs:string"/> + <xs:element name="parentPassword" type="xs:string"/> + <xs:element name="parentRyaInstanceName" type="xs:string"/> + <xs:element name="parentTablePrefix" type="xs:string"/> + <xs:element name="parentTomcatUrl" type="xs:string"/> + <xs:element name="parentDBType" type="mc:DBType"/> + <xs:element name="parentPort" type="mc:Port"/> + + <xs:element name="childHostname" type="xs:string"/> + <xs:element name="childUsername" type="xs:string"/> + <xs:element name="childPassword" type="xs:string"/> + <xs:element name="childRyaInstanceName" type="xs:string"/> + <xs:element name="childTablePrefix" type="xs:string"/> + <xs:element name="childTomcatUrl" type="xs:string"/> + <xs:element name="childDBType" type="mc:DBType"/> + <xs:element name="childPort" type="mc:Port"/> + + <xs:element name="mergePolicy" type="mc:MergePolicy"/> + + <xs:element name="useNtpServer" type="xs:boolean"/> + <xs:element name="ntpServerHost" type="xs:string"/> + <xs:element name="toolStartTime" type="xs:string"/> + </xs:sequence> + </xs:complexType> + + <xs:simpleType name="MergePolicy"> + <xs:restriction base="xs:string"> + <xs:enumeration value="timestamp"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="DBType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="accumulo"/> + <xs:enumeration value="mongo"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="Port"> + <xs:annotation> + <xs:documentation> + Port number in the range [1, 65536]. + </xs:documentation> + </xs:annotation> + + <xs:restriction base="xs:unsignedShort"> + <xs:minInclusive value="1"/> + </xs:restriction> + </xs:simpleType> +</schema> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/24c71838/extras/rya.export/pom.xml ---------------------------------------------------------------------- diff --git a/extras/rya.export/pom.xml b/extras/rya.export/pom.xml index 89f6d27..92c715c 100644 --- a/extras/rya.export/pom.xml +++ b/extras/rya.export/pom.xml @@ -36,7 +36,8 @@ under the License. <packaging>pom</packaging> - <modules> + <modules> + <module>export.api</module> </modules> <properties>
