http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/graphdb/titan0/src/test/java/org/apache/atlas/repository/graphdb/titan0/Titan0DatabaseTest.java ---------------------------------------------------------------------- diff --git a/graphdb/titan0/src/test/java/org/apache/atlas/repository/graphdb/titan0/Titan0DatabaseTest.java b/graphdb/titan0/src/test/java/org/apache/atlas/repository/graphdb/titan0/Titan0DatabaseTest.java new file mode 100644 index 0000000..6c2ea26 --- /dev/null +++ b/graphdb/titan0/src/test/java/org/apache/atlas/repository/graphdb/titan0/Titan0DatabaseTest.java @@ -0,0 +1,428 @@ +/** + * 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.atlas.repository.graphdb.titan0; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.apache.atlas.AtlasException; +import org.apache.atlas.repository.Constants; +import org.apache.atlas.repository.graphdb.AtlasEdge; +import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; +import org.apache.atlas.repository.graphdb.AtlasGraph; +import org.apache.atlas.repository.graphdb.AtlasGraphManagement; +import org.apache.atlas.repository.graphdb.AtlasGraphQuery; +import org.apache.atlas.repository.graphdb.AtlasGraphQuery.ComparisionOperator; +import org.apache.atlas.repository.graphdb.AtlasPropertyKey; +import org.apache.atlas.repository.graphdb.AtlasVertex; +import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; +import org.apache.atlas.typesystem.types.Multiplicity; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + +/** + * Sanity test of basic graph operations using the Titan 0.5.4 graphdb + * abstraction layer implementation. + */ +public class Titan0DatabaseTest { + + private AtlasGraph<?, ?> atlasGraph; + + private <V, E> AtlasGraph<V, E> getGraph() { + if (atlasGraph == null) { + Titan0Database db = new Titan0Database(); + atlasGraph = db.getGraph(); + AtlasGraphManagement mgmt = atlasGraph.getManagementSystem(); + // create the index (which defines these properties as being mult + // many) + for (String propertyName : AtlasGraphManagement.MULTIPLICITY_MANY_PROPERTY_KEYS) { + AtlasPropertyKey propertyKey = mgmt.getPropertyKey(propertyName); + if (propertyKey == null) { + propertyKey = mgmt.makePropertyKey(propertyName, String.class, Multiplicity.SET); + mgmt.createCompositeIndex(propertyName, propertyKey, false); + } + } + mgmt.commit(); + } + return (AtlasGraph<V, E>) atlasGraph; + } + + @AfterClass + public void cleanup() { + atlasGraph.clear(); + atlasGraph = null; + + } + + @Test + public <V, E> void testPropertyDataTypes() { + + // primitives + AtlasGraph<V, E> graph = getGraph(); + + testProperty(graph, "booleanProperty", Boolean.TRUE); + testProperty(graph, "booleanProperty", Boolean.FALSE); + testProperty(graph, "booleanProperty", new Boolean(Boolean.TRUE)); + testProperty(graph, "booleanProperty", new Boolean(Boolean.FALSE)); + + testProperty(graph, "byteProperty", Byte.MAX_VALUE); + testProperty(graph, "byteProperty", Byte.MIN_VALUE); + testProperty(graph, "byteProperty", new Byte(Byte.MAX_VALUE)); + testProperty(graph, "byteProperty", new Byte(Byte.MIN_VALUE)); + + testProperty(graph, "shortProperty", Short.MAX_VALUE); + testProperty(graph, "shortProperty", Short.MIN_VALUE); + testProperty(graph, "shortProperty", new Short(Short.MAX_VALUE)); + testProperty(graph, "shortProperty", new Short(Short.MIN_VALUE)); + + testProperty(graph, "intProperty", Integer.MAX_VALUE); + testProperty(graph, "intProperty", Integer.MIN_VALUE); + testProperty(graph, "intProperty", new Integer(Integer.MAX_VALUE)); + testProperty(graph, "intProperty", new Integer(Integer.MIN_VALUE)); + + testProperty(graph, "longProperty", Long.MIN_VALUE); + testProperty(graph, "longProperty", Long.MAX_VALUE); + testProperty(graph, "longProperty", new Long(Long.MIN_VALUE)); + testProperty(graph, "longProperty", new Long(Long.MAX_VALUE)); + + testProperty(graph, "doubleProperty", Double.MAX_VALUE); + testProperty(graph, "doubleProperty", Double.MIN_VALUE); + testProperty(graph, "doubleProperty", new Double(Double.MAX_VALUE)); + testProperty(graph, "doubleProperty", new Double(Double.MIN_VALUE)); + + testProperty(graph, "floatProperty", Float.MAX_VALUE); + testProperty(graph, "floatProperty", Float.MIN_VALUE); + testProperty(graph, "floatProperty", new Float(Float.MAX_VALUE)); + testProperty(graph, "floatProperty", new Float(Float.MIN_VALUE)); + + // enumerations - TypeCategory + testProperty(graph, "typeCategoryProperty", TypeCategory.CLASS); + + // biginteger + testProperty(graph, "bigIntegerProperty", + new BigInteger(String.valueOf(Long.MAX_VALUE)).multiply(BigInteger.TEN)); + + // bigdecimal + BigDecimal bigDecimal = new BigDecimal(Double.MAX_VALUE); + testProperty(graph, "bigDecimalProperty", bigDecimal.multiply(bigDecimal)); + } + + private <V, E> void testProperty(AtlasGraph<V, E> graph, String name, Object value) { + + AtlasVertex<V, E> vertex = graph.addVertex(); + vertex.setProperty(name, value); + assertEquals(value, vertex.getProperty(name, value.getClass())); + AtlasVertex<V, E> loaded = graph.getVertex(vertex.getId().toString()); + assertEquals(value, loaded.getProperty(name, value.getClass())); + } + + @Test + public <V, E> void testMultiplicityOnePropertySupport() { + + AtlasGraph<V, E> graph = (AtlasGraph<V, E>) getGraph(); + + AtlasVertex<V, E> vertex = graph.addVertex(); + vertex.setProperty("name", "Jeff"); + vertex.setProperty("location", "Littleton"); + assertEquals("Jeff", vertex.getProperty("name", String.class)); + assertEquals("Littleton", vertex.getProperty("location", String.class)); + + AtlasVertex<V, E> vertexCopy = graph.getVertex(vertex.getId().toString()); + + assertEquals("Jeff", vertexCopy.getProperty("name", String.class)); + assertEquals("Littleton", vertexCopy.getProperty("location", String.class)); + + assertTrue(vertexCopy.getPropertyKeys().contains("name")); + assertTrue(vertexCopy.getPropertyKeys().contains("location")); + + assertTrue(vertexCopy.getPropertyValues("name", String.class).contains("Jeff")); + assertTrue(vertexCopy.getPropertyValues("location", String.class).contains("Littleton")); + assertTrue(vertexCopy.getPropertyValues("test", String.class).isEmpty()); + assertNull(vertexCopy.getProperty("test", String.class)); + + vertex.removeProperty("name"); + assertFalse(vertex.getPropertyKeys().contains("name")); + assertNull(vertex.getProperty("name", String.class)); + assertTrue(vertex.getPropertyValues("name", String.class).isEmpty()); + + vertexCopy = graph.getVertex(vertex.getId().toString()); + assertFalse(vertexCopy.getPropertyKeys().contains("name")); + assertNull(vertexCopy.getProperty("name", String.class)); + assertTrue(vertexCopy.getPropertyValues("name", String.class).isEmpty()); + + } + + @Test + public <V, E> void testRemoveEdge() { + + AtlasGraph<V, E> graph = (AtlasGraph<V, E>) getGraph(); + AtlasVertex<V, E> v1 = graph.addVertex(); + AtlasVertex<V, E> v2 = graph.addVertex(); + + AtlasEdge<V, E> edge = graph.addEdge(v1, v2, "knows"); + + // make sure the edge exists + AtlasEdge<V, E> edgeCopy = graph.getEdge(edge.getId().toString()); + assertNotNull(edgeCopy); + assertEquals(edgeCopy, edge); + + graph.removeEdge(edge); + + edgeCopy = graph.getEdge(edge.getId().toString()); + // should return null now, since edge was deleted + assertNull(edgeCopy); + + } + + @Test + public <V, E> void testRemoveVertex() { + + AtlasGraph<V, E> graph = (AtlasGraph<V, E>) getGraph(); + + AtlasVertex<V, E> v1 = graph.addVertex(); + + assertNotNull(graph.getVertex(v1.getId().toString())); + + graph.removeVertex(v1); + + assertNull(graph.getVertex(v1.getId().toString())); + } + + @Test + public <V, E> void testGetEdges() { + + AtlasGraph<V, E> graph = (AtlasGraph<V, E>) getGraph(); + AtlasVertex<V, E> v1 = graph.addVertex(); + AtlasVertex<V, E> v2 = graph.addVertex(); + AtlasVertex<V, E> v3 = graph.addVertex(); + + AtlasEdge<V, E> knows = graph.addEdge(v2, v1, "knows"); + AtlasEdge<V, E> eats = graph.addEdge(v3, v1, "eats"); + AtlasEdge<V, E> drives = graph.addEdge(v3, v2, "drives"); + AtlasEdge<V, E> sleeps = graph.addEdge(v2, v3, "sleeps"); + + assertEdgesMatch(v1.getEdges(AtlasEdgeDirection.IN), knows, eats); + assertEdgesMatch(v1.getEdges(AtlasEdgeDirection.OUT)); + assertEdgesMatch(v1.getEdges(AtlasEdgeDirection.BOTH), knows, eats); + + assertEdgesMatch(v1.getEdges(AtlasEdgeDirection.IN, "knows"), knows); + assertEdgesMatch(v1.getEdges(AtlasEdgeDirection.OUT, "knows")); + assertEdgesMatch(v1.getEdges(AtlasEdgeDirection.BOTH, "knows"), knows); + + assertEdgesMatch(v2.getEdges(AtlasEdgeDirection.IN), drives); + assertEdgesMatch(v2.getEdges(AtlasEdgeDirection.OUT), knows, sleeps); + assertEdgesMatch(v2.getEdges(AtlasEdgeDirection.BOTH), knows, sleeps, drives); + + assertEdgesMatch(v2.getEdges(AtlasEdgeDirection.BOTH, "delivers")); + } + + private <V, E> void assertEdgesMatch(Iterable<AtlasEdge<V, E>> edgesIt, AtlasEdge<V, E>... expected) { + List<AtlasEdge<V, E>> edges = toList(edgesIt); + assertEquals(expected.length, edges.size()); + for (AtlasEdge<V, E> edge : expected) { + assertTrue(edges.contains(edge)); + } + } + + @Test + public <V, E> void testMultiplictyManyPropertySupport() { + + AtlasGraph<V, E> graph = getGraph(); + + AtlasVertex<V, E> vertex = graph.addVertex(); + String vertexId = vertex.getId().toString(); + vertex.setProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait1"); + vertex.setProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait2"); + assertEquals(vertex.getPropertyValues(Constants.TRAIT_NAMES_PROPERTY_KEY, String.class).size(), 2); + vertex.addProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait3"); + vertex.addProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait4"); + + assertTrue(vertex.getPropertyKeys().contains(Constants.TRAIT_NAMES_PROPERTY_KEY)); + validateMultManyPropertiesInVertex(vertex); + // fetch a copy of the vertex, make sure result + // is the same + + validateMultManyPropertiesInVertex(graph.getVertex(vertexId)); + + } + + private <V, E> void validateMultManyPropertiesInVertex(AtlasVertex<V, E> vertex) { + + assertTrue(vertex.getPropertyKeys().contains(Constants.TRAIT_NAMES_PROPERTY_KEY)); + Collection<String> traitNames = vertex.getPropertyValues(Constants.TRAIT_NAMES_PROPERTY_KEY, String.class); + assertTrue(traitNames.contains("trait1")); + assertTrue(traitNames.contains("trait2")); + assertTrue(traitNames.contains("trait3")); + assertTrue(traitNames.contains("trait4")); + + try { + vertex.getProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, String.class); + fail("Expected exception not thrown"); + } catch (IllegalStateException expected) { + // multiple property values exist + } + } + + @Test + public <V, E> void testListProperties() throws AtlasException { + + AtlasGraph<V, E> graph = getGraph(); + AtlasVertex<V, E> vertex = graph.addVertex(); + vertex.setListProperty("colors", Arrays.asList(new String[] { "red", "blue", "green" })); + List<String> colors = vertex.getListProperty("colors"); + assertTrue(colors.contains("red")); + assertTrue(colors.contains("blue")); + assertTrue(colors.contains("green")); + + AtlasVertex<V, E> vertexCopy = graph.getVertex(vertex.getId().toString()); + colors = vertexCopy.getListProperty("colors"); + assertTrue(colors.contains("red")); + assertTrue(colors.contains("blue")); + assertTrue(colors.contains("green")); + + } + + @Test + public <V, E> void testRemoveProperty() { + + AtlasGraph<V, E> graph = getGraph(); + AtlasVertex<V, E> vertex = graph.addVertex(); + vertex.addProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait1"); + vertex.addProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait1"); + vertex.setProperty("name", "Jeff"); + + // remove existing property - multiplicity one + vertex.removeProperty("jeff"); + + assertFalse(vertex.getPropertyKeys().contains("jeff")); + + // remove existing property - multiplicity many + vertex.removeProperty(Constants.TRAIT_NAMES_PROPERTY_KEY); + assertFalse(vertex.getPropertyKeys().contains(Constants.TRAIT_NAMES_PROPERTY_KEY)); + + AtlasVertex<V, E> vertexCopy = graph.getVertex(vertex.getId().toString()); + assertFalse(vertexCopy.getPropertyKeys().contains("jeff")); + assertFalse(vertexCopy.getPropertyKeys().contains(Constants.TRAIT_NAMES_PROPERTY_KEY)); + + // remove non-existing property + vertex.removeProperty(Constants.TRAIT_NAMES_PROPERTY_KEY); + vertex.removeProperty("jeff"); + + } + + @Test + public <V, E> void getGetGraphQueryForVertices() { + + AtlasGraph<V, E> graph = getGraph(); + + AtlasVertex<V, E> v1 = graph.addVertex(); + AtlasVertex<V, E> v2 = graph.addVertex(); + AtlasVertex<V, E> v3 = graph.addVertex(); + + v1.setProperty("name", "Jeff"); + v1.setProperty("weight", 1); + + v2.setProperty("name", "Fred"); + v2.setProperty("weight", 2); + + v3.setProperty("name", "Chris"); + v3.setProperty("weight", 3); + + AtlasEdge<V, E> knows = graph.addEdge(v2, v1, "knows"); + knows.setProperty("weight", 1); + AtlasEdge<V, E> eats = graph.addEdge(v3, v1, "eats"); + eats.setProperty("weight", 2); + AtlasEdge<V, E> drives = graph.addEdge(v3, v2, "drives"); + drives.setProperty("weight", 3); + + AtlasEdge<V, E> sleeps = graph.addEdge(v2, v3, "sleeps"); + sleeps.setProperty("weight", 4); + + testExecuteGraphQuery("name", null, "Jeff", v1); + testExecuteGraphQuery("weight", ComparisionOperator.EQUAL, 2, v2); + testExecuteGraphQuery("weight", ComparisionOperator.GREATER_THAN_EQUAL, 2, v2, v3); + testExecuteGraphQuery("weight", ComparisionOperator.LESS_THAN_EQUAL, 2, v2, v1); + + } + + private <V, E> void testExecuteGraphQuery(String property, ComparisionOperator op, Object value, + AtlasVertex<V, E>... expected) { + AtlasGraph<V, E> graph = getGraph(); + AtlasGraphQuery<V, E> query = graph.query(); + if (op != null) { + query.has(property, op, value); + } else { + query.has(property, value); + } + Iterable<? extends AtlasVertex<V, E>> result = query.vertices(); + List<AtlasVertex<V, E>> list = toList(result); + assertEquals(expected.length, list.size()); + for (AtlasVertex<V, E> vertex : expected) { + assertTrue(list.contains(vertex)); + } + } + + @Test + public <V, E> void testAddMultManyPropertyValueTwice() { + + AtlasGraph<V, E> graph = getGraph(); + String vertexId; + + AtlasVertex<V, E> vertex = graph.addVertex(); + vertexId = vertex.getId().toString(); + vertex.setProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait1"); + vertex.setProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait1"); + vertex.addProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait2"); + vertex.addProperty(Constants.TRAIT_NAMES_PROPERTY_KEY, "trait2"); + + validateDuplicatePropertyVertex(vertex); + + // fetch a copy of the vertex, make sure result is the same + + validateDuplicatePropertyVertex(graph.getVertex(vertexId)); + } + + private <V, E> void validateDuplicatePropertyVertex(AtlasVertex<V, E> vertex) { + assertEquals(2, vertex.getPropertyValues(Constants.TRAIT_NAMES_PROPERTY_KEY, String.class).size()); + assertTrue(vertex.getPropertyKeys().contains(Constants.TRAIT_NAMES_PROPERTY_KEY)); + Collection<String> traitNames = vertex.getPropertyValues(Constants.TRAIT_NAMES_PROPERTY_KEY, String.class); + assertTrue(traitNames.contains("trait1")); + assertTrue(traitNames.contains("trait2")); + } + + private static <T> List<T> toList(Iterable<? extends T> iterable) { + List<T> result = new ArrayList<T>(); + for (T item : iterable) { + result.add(item); + } + return result; + } + +}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/graphdb/titan0/src/test/java/org/apache/atlas/repository/graphdb/titan0/Titan0DatabaseValidationTest.java ---------------------------------------------------------------------- diff --git a/graphdb/titan0/src/test/java/org/apache/atlas/repository/graphdb/titan0/Titan0DatabaseValidationTest.java b/graphdb/titan0/src/test/java/org/apache/atlas/repository/graphdb/titan0/Titan0DatabaseValidationTest.java new file mode 100644 index 0000000..341c064 --- /dev/null +++ b/graphdb/titan0/src/test/java/org/apache/atlas/repository/graphdb/titan0/Titan0DatabaseValidationTest.java @@ -0,0 +1,77 @@ +/** + * 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.atlas.repository.graphdb.titan0; + +import org.apache.atlas.ApplicationProperties; +import org.apache.atlas.AtlasException; +import org.apache.atlas.repository.graphdb.AtlasGraph; +import org.apache.commons.configuration.Configuration; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +@Test +public class Titan0DatabaseValidationTest { + + private Configuration configuration; + private AtlasGraph<?, ?> graph; + + @BeforeTest + public void setUp() throws AtlasException { + // First get Instance + graph = new Titan0Graph(); + configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(), + Titan0Database.GRAPH_PREFIX); + } + + @AfterClass + public void tearDown() throws Exception { + try { + graph.shutdown(); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + graph.clear(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testValidate() throws AtlasException { + try { + Titan0Database.validateIndexBackend(configuration); + } catch (Exception e) { + Assert.fail("Unexpected exception ", e); + } + + // Change backend + configuration.setProperty(Titan0Database.INDEX_BACKEND_CONF, Titan0Database.INDEX_BACKEND_LUCENE); + try { + Titan0Database.validateIndexBackend(configuration); + Assert.fail("Expected exception"); + } catch (Exception e) { + Assert.assertEquals(e.getMessage(), + "Configured Index Backend lucene differs from earlier configured " + + "Index Backend elasticsearch. Aborting!"); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/graphdb/titan0/src/test/resources/atlas-application.properties ---------------------------------------------------------------------- diff --git a/graphdb/titan0/src/test/resources/atlas-application.properties b/graphdb/titan0/src/test/resources/atlas-application.properties new file mode 100644 index 0000000..1e8963e --- /dev/null +++ b/graphdb/titan0/src/test/resources/atlas-application.properties @@ -0,0 +1,97 @@ +# +# 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. +# + +######### Graph Database to Use ######### +atlas.graphdb.backend=org.apache.atlas.repository.graphdb.titan0.Titan0Database + +######### Atlas Server Configs ######### +atlas.rest.address=http://localhost:31000 + +######### Graph Database Configs ######### +# Graph Storage +atlas.graph.storage.backend=${titan.storage.backend} + +# Graph Search Index Backend +atlas.graph.index.search.backend=${titan.index.backend} + +#Berkeley storage directory +atlas.graph.storage.directory=${sys:atlas.data}/berkley + +#hbase +#For standalone mode , specify localhost +#for distributed mode, specify zookeeper quorum here - For more information refer http://s3.thinkaurelius.com/docs/titan/current/hbase.html#_remote_server_mode_2 + +atlas.graph.storage.hostname=${titan.storage.hostname} +atlas.graph.storage.hbase.regions-per-server=1 +atlas.graph.storage.lock.wait-time=10000 + +#ElasticSearch +atlas.graph.index.search.directory=${sys:atlas.data}/es +atlas.graph.index.search.elasticsearch.client-only=false +atlas.graph.index.search.elasticsearch.local-mode=true +atlas.graph.index.search.elasticsearch.create.sleep=2000 + +# Solr cloud mode properties +atlas.graph.index.search.solr.mode=cloud +atlas.graph.index.search.solr.zookeeper-url=${solr.zk.address} + + +######### Hive Lineage Configs ######### +# This models reflects the base super types for Data and Process +#atlas.lineage.hive.table.type.name=DataSet +#atlas.lineage.hive.process.type.name=Process +#atlas.lineage.hive.process.inputs.name=inputs +#atlas.lineage.hive.process.outputs.name=outputs + +## Schema +atlas.lineage.hive.table.schema.query.hive_table=hive_table where name='%s'\, columns + +######### Notification Configs ######### +atlas.notification.embedded=true + +atlas.kafka.zookeeper.connect=localhost:19026 +atlas.kafka.bootstrap.servers=localhost:19027 +atlas.kafka.data=${sys:atlas.data}/kafka +atlas.kafka.zookeeper.session.timeout.ms=4000 +atlas.kafka.zookeeper.sync.time.ms=20 +atlas.kafka.consumer.timeout.ms=100 +atlas.kafka.auto.commit.interval.ms=100 +atlas.kafka.hook.group.id=atlas +atlas.kafka.entities.group.id=atlas_entities + +######### Entity Audit Configs ######### +atlas.audit.hbase.tablename=ATLAS_ENTITY_AUDIT_EVENTS +atlas.audit.zookeeper.session.timeout.ms=1000 +atlas.audit.hbase.zookeeper.quorum=localhost +atlas.audit.hbase.zookeeper.property.clientPort=19026 + +######### Security Properties ######### + +# SSL config +atlas.enableTLS=false +atlas.server.https.port=31443 + +######### Security Properties ######### + +hbase.security.authentication=simple + +atlas.hook.falcon.synchronous=true +######### High Availability Configuration ######## +atlas.server.ha.enabled=false +#atlas.server.ids=id1 +#atlas.server.address.id1=localhost:21000 http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 2384494..ac984e0 100755 --- a/pom.xml +++ b/pom.xml @@ -434,7 +434,8 @@ <titan.storage.backend>berkeleyje</titan.storage.backend> <titan.index.backend>elasticsearch</titan.index.backend> - <entity.repository.impl>org.apache.atlas.repository.audit.InMemoryEntityAuditRepository</entity.repository.impl> + <entity.repository.impl>org.apache.atlas.repository.audit.InMemoryEntityAuditRepository</entity.repository.impl> + <atlas.surefire.options></atlas.surefire.options> </properties> <profiles> @@ -446,10 +447,10 @@ </activation> <properties> <titan.storage.backend>hbase</titan.storage.backend> - <titan.index.backend>solr5</titan.index.backend> + <titan.index.backend>solr</titan.index.backend> <solr.zk.address>localhost:9983</solr.zk.address> <titan.storage.hostname>localhost</titan.storage.hostname> - <entity.repository.impl>org.apache.atlas.repository.audit.HBaseBasedAuditRepository</entity.repository.impl> + <entity.repository.impl>org.apache.atlas.repository.audit.HBaseBasedAuditRepository</entity.repository.impl> </properties> </profile> @@ -487,7 +488,6 @@ <module>notification</module> <module>client</module> <module>graphdb</module> - <module>titan</module> <module>repository</module> <module>authorization</module> <module>catalog</module> @@ -683,6 +683,11 @@ </exclusions> </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-auth</artifactId> + <version>${hadoop.version}</version> + </dependency> <dependency> <groupId>org.apache.hadoop</groupId> @@ -874,58 +879,7 @@ </dependency> <!-- Graph DB --> - <dependency> - <groupId>com.tinkerpop.blueprints</groupId> - <artifactId>blueprints-core</artifactId> - <version>${tinkerpop.version}</version> - </dependency> - - <dependency> - <groupId>com.thinkaurelius.titan</groupId> - <artifactId>titan-core</artifactId> - <version>${titan.version}</version> - <exclusions> - <!-- rexster does not work with servlet-api --> - <exclusion> - <groupId>com.tinkerpop.rexster</groupId> - <artifactId>rexster-core</artifactId> - </exclusion> - <exclusion> - <groupId>com.tinkerpop.rexster</groupId> - <artifactId>rexster-server</artifactId> - </exclusion> - <!-- asm 4.0 does not work with jersey asm 3.1 --> - <exclusion> - <groupId>com.tinkerpop</groupId> - <artifactId>frames</artifactId> - </exclusion> - <exclusion> - <groupId>com.esotericsoftware.reflectasm</groupId> - <artifactId>reflectasm</artifactId> - </exclusion> - <exclusion> - <groupId>org.ow2.asm</groupId> - <artifactId>asm</artifactId> - </exclusion> - <exclusion> <!-- GPL license imported from ganglia --> - <groupId>org.acplt</groupId> - <artifactId>oncrpc</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>com.thinkaurelius.titan</groupId> - <artifactId>titan-berkeleyje</artifactId> - <version>${titan.version}</version> - </dependency> - - <dependency> - <groupId>com.thinkaurelius.titan</groupId> - <artifactId>titan-hbase</artifactId> - <version>${titan.version}</version> - </dependency> - + <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-client</artifactId> @@ -980,12 +934,6 @@ </dependency> <dependency> - <groupId>com.thinkaurelius.titan</groupId> - <artifactId>titan-es</artifactId> - <version>${titan.version}</version> - </dependency> - - <dependency> <groupId>com.vividsolutions</groupId> <artifactId>jts</artifactId> <version>1.13</version> @@ -1016,6 +964,10 @@ <artifactId>*</artifactId> <groupId>org.apache.lucene</groupId> </exclusion> + <exclusion> + <artifactId>*</artifactId> + <groupId>org.apache.hadoop</groupId> + </exclusion> </exclusions> </dependency> @@ -1025,19 +977,6 @@ <version>${solr.version}</version> </dependency> - <dependency> - <groupId>com.thinkaurelius.titan</groupId> - <artifactId>titan-lucene</artifactId> - <version>${titan.version}</version> - <!--<scope>test</scope>--> - </dependency> - - <dependency> - <groupId>com.tinkerpop.gremlin</groupId> - <artifactId>gremlin-java</artifactId> - <version>${tinkerpop.version}</version> - </dependency> - <!-- atlas modules --> <dependency> <groupId>org.apache.atlas</groupId> @@ -1055,7 +994,13 @@ <dependency> <groupId>org.apache.atlas</groupId> - <artifactId>atlas-titan</artifactId> + <artifactId>atlas-graphdb-api</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.atlas</groupId> + <artifactId>atlas-graphdb-titan0</artifactId> <version>${project.version}</version> </dependency> @@ -1576,6 +1521,14 @@ </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-remote-resources-plugin</artifactId> + <version>1.5</version> + <configuration> + <excludeGroupIds>org.restlet.jee</excludeGroupIds> + </configuration> + </plugin> </plugins> </pluginManagement> @@ -1628,7 +1581,7 @@ <redirectTestOutputToFile>true</redirectTestOutputToFile> <argLine>-Djava.awt.headless=true -Dproject.version=${project.version} -Dhadoop.tmp.dir="${project.build.directory}/tmp-hadoop-${user.name}" - -Xmx1024m -XX:MaxPermSize=512m -Djava.net.preferIPv4Stack=true + -Xmx1024m -XX:MaxPermSize=512m -Djava.net.preferIPv4Stack=true ${atlas.surefire.options} </argLine> <skip>${skipUTs}</skip> </configuration> @@ -1654,7 +1607,7 @@ <redirectTestOutputToFile>true</redirectTestOutputToFile> <argLine>-Djava.awt.headless=true -Dproject.version=${project.version} -Dhadoop.tmp.dir="${project.build.directory}/tmp-hadoop-${user.name}" - -Xmx1024m -XX:MaxPermSize=512m + -Xmx1024m -XX:MaxPermSize=512m ${atlas.surefire.options} </argLine> <skip>${skipITs}</skip> <parallel>none</parallel> @@ -1727,7 +1680,11 @@ <useEclipseDefaultExcludes>true</useEclipseDefaultExcludes> <excludeSubProjects>true</excludeSubProjects> <excludes> + <exclude>**/dependency-reduced-pom.xml</exclude> + <exclude>.reviewboardrc</exclude> <exclude>3party-licenses/**</exclude> + <exclude>**/.cache-main</exclude> + <exclude>**/.checkstyle</exclude> <exclude>*.txt</exclude> <exclude>**/*.json</exclude> <exclude>.pc/**</exclude> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 885afd4..7c8e008 100644 --- a/release-log.txt +++ b/release-log.txt @@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES: ATLAS-1060 Add composite indexes for exact match performance improvements for all attributes (sumasai via shwethags) ALL CHANGES: +ATLAS-693 Titan 0.5.4 implementation of the graph db abstraction {jnhagelb via dkantor) ATLAS-1099 UI : multiple tag assign button hides wrongly (Kalyanikashikar via sumasai) ATLAS-1087 Provide an option to turn off persisting entity definition in audits (sumasai, shwethags) ATLAS-1097 Fix a potential NPE issue flagged by Coverity scan (mneethiraj via shwethags) http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/repository/pom.xml ---------------------------------------------------------------------- diff --git a/repository/pom.xml b/repository/pom.xml index 3d525e0..663ac87 100755 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -49,7 +49,12 @@ <dependency> <groupId>org.apache.atlas</groupId> - <artifactId>atlas-titan</artifactId> + <artifactId>atlas-graphdb-api</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.atlas</groupId> + <artifactId>atlas-graphdb-titan0</artifactId> </dependency> <dependency> @@ -83,16 +88,6 @@ </dependency> <dependency> - <groupId>com.tinkerpop.blueprints</groupId> - <artifactId>blueprints-core</artifactId> - </dependency> - - <dependency> - <groupId>com.tinkerpop.gremlin</groupId> - <artifactId>gremlin-java</artifactId> - </dependency> - - <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-reflect</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java b/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java index 3486436..f1ef140 100755 --- a/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java +++ b/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java @@ -75,9 +75,12 @@ public class RepositoryMetadataModule extends com.google.inject.AbstractModule { // bind the ITypeStore interface to an implementation bind(ITypeStore.class).to(GraphBackedTypeStore.class).asEagerSingleton(); + //GraphBackedSearchIndexer must be an eager singleton to force the search index creation to happen before + //we try to restore the type system (otherwise we'll end up running queries + //before we have any indices during the initial graph setup) Multibinder<TypesChangeListener> typesChangeListenerBinder = Multibinder.newSetBinder(binder(), TypesChangeListener.class); - typesChangeListenerBinder.addBinding().to(GraphBackedSearchIndexer.class); + typesChangeListenerBinder.addBinding().to(GraphBackedSearchIndexer.class).asEagerSingleton(); // bind the MetadataService interface to an implementation bind(MetadataService.class).to(DefaultMetadataService.class).asEagerSingleton(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/repository/src/main/java/org/apache/atlas/repository/Constants.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/Constants.java b/repository/src/main/java/org/apache/atlas/repository/Constants.java deleted file mode 100755 index 893f1b6..0000000 --- a/repository/src/main/java/org/apache/atlas/repository/Constants.java +++ /dev/null @@ -1,101 +0,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. - */ - -package org.apache.atlas.repository; - -import org.apache.atlas.typesystem.types.AttributeInfo; -import org.apache.atlas.typesystem.types.DataTypes; -import org.apache.atlas.typesystem.types.utils.TypesUtil; - -public final class Constants { - - /** - * Globally Unique identifier property key. - */ - - public static final String INTERNAL_PROPERTY_KEY_PREFIX = "__"; - public static final String GUID_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "guid"; - - /** - * Entity type name property key. - */ - public static final String ENTITY_TYPE_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "typeName"; - - /** - * Entity type's super types property key. - */ - public static final String SUPER_TYPES_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "superTypeNames"; - - /** - * Full-text for the entity for enabling full-text search. - */ - //weird issue in TitanDB if __ added to this property key. Not adding it for now - public static final String ENTITY_TEXT_PROPERTY_KEY = "entityText"; - - /** - * Properties for type store graph - */ - public static final String TYPE_CATEGORY_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "type.category"; - public static final String VERTEX_TYPE_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "type"; - public static final String TYPENAME_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "type.name"; - public static final String TYPEDESCRIPTION_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "type.description"; - - /** - * Trait names property key and index name. - */ - public static final String TRAIT_NAMES_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "traitNames"; - - public static final String VERSION_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "version"; - public static final String STATE_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "state"; - - public static final String TIMESTAMP_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "timestamp"; - public static final String MODIFICATION_TIMESTAMP_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "modificationTimestamp"; - - public static AttributeInfo getAttributeInfoForSystemAttributes(String field) { - switch (field) { - case STATE_PROPERTY_KEY: - case GUID_PROPERTY_KEY: - return TypesUtil.newAttributeInfo(field, DataTypes.STRING_TYPE); - - case TIMESTAMP_PROPERTY_KEY: - case MODIFICATION_TIMESTAMP_PROPERTY_KEY: - return TypesUtil.newAttributeInfo(field, DataTypes.LONG_TYPE); - } - return null; - } - - /** - * search backing index name. - */ - public static final String BACKING_INDEX = "search"; - - /** - * search backing index name for vertex keys. - */ - public static final String VERTEX_INDEX = "vertex_index"; - - /** - * search backing index name for edge labels. - */ - public static final String EDGE_INDEX = "edge_index"; - - public static final String FULLTEXT_INDEX = "fulltext_index"; - - private Constants() { - } -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java index 81fb76e..0a90bda 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java @@ -18,18 +18,14 @@ package org.apache.atlas.repository.graph; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanProperty; -import com.thinkaurelius.titan.core.TitanVertex; -import com.tinkerpop.blueprints.Direction; -import com.tinkerpop.blueprints.Edge; -import com.tinkerpop.blueprints.Element; -import com.tinkerpop.blueprints.Graph; -import com.tinkerpop.blueprints.GraphQuery; -import com.tinkerpop.blueprints.Vertex; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.UUID; + import org.apache.atlas.AtlasException; import org.apache.atlas.RequestContext; import org.apache.atlas.repository.Constants; @@ -44,17 +40,23 @@ import org.apache.atlas.typesystem.types.DataTypes; import org.apache.atlas.typesystem.types.HierarchicalType; import org.apache.atlas.typesystem.types.IDataType; import org.apache.atlas.typesystem.types.TypeSystem; +import org.apache.atlas.typesystem.types.utils.TypesUtil; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.UUID; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.core.TitanProperty; +import com.thinkaurelius.titan.core.TitanVertex; +import com.tinkerpop.blueprints.Direction; +import com.tinkerpop.blueprints.Edge; +import com.tinkerpop.blueprints.Element; +import com.tinkerpop.blueprints.Graph; +import com.tinkerpop.blueprints.GraphQuery; +import com.tinkerpop.blueprints.Vertex; /** * Utility class for graph operations. @@ -295,7 +297,7 @@ public final class GraphHelper { /** * Remove the specified edge from the graph. - * + * * @param edge */ public void removeEdge(Edge edge) { @@ -304,10 +306,10 @@ public final class GraphHelper { titanGraph.removeEdge(edge); LOG.info("Removed {}", edgeString); } - + /** * Remove the specified vertex from the graph. - * + * * @param vertex */ public void removeVertex(Vertex vertex) { @@ -488,4 +490,17 @@ public final class GraphHelper { } return key; } + public static AttributeInfo getAttributeInfoForSystemAttributes(String field) { + switch (field) { + case Constants.STATE_PROPERTY_KEY: + case Constants.GUID_PROPERTY_KEY: + return TypesUtil.newAttributeInfo(field, DataTypes.STRING_TYPE); + + case Constants.TIMESTAMP_PROPERTY_KEY: + case Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY: + return TypesUtil.newAttributeInfo(field, DataTypes.LONG_TYPE); + } + return null; + } + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/repository/src/main/java/org/apache/atlas/repository/graph/TitanGraphProvider.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/TitanGraphProvider.java b/repository/src/main/java/org/apache/atlas/repository/graph/TitanGraphProvider.java index 2cc1a50..7a5e6a9 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/TitanGraphProvider.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/TitanGraphProvider.java @@ -18,122 +18,33 @@ package org.apache.atlas.repository.graph; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Provides; -import com.thinkaurelius.titan.core.TitanFactory; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.schema.TitanManagement; -import com.thinkaurelius.titan.diskstorage.StandardIndexProvider; -import com.thinkaurelius.titan.diskstorage.solr.Solr5Index; -import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasException; +import org.apache.atlas.repository.graphdb.titan0.Titan0Database; import org.apache.commons.configuration.Configuration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import javax.inject.Singleton; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.Map; +import com.thinkaurelius.titan.core.TitanGraph; /** - * Default implementation for Graph Provider that doles out Titan Graph. + * Temporary TitanGraphProvider to use until the graph database abstraction + * layer is fully in place. Delegates to the Titan 0.5.4 implementation. This + * will be removed once the abstraction layer is being used. */ public class TitanGraphProvider implements GraphProvider<TitanGraph> { - private static final Logger LOG = LoggerFactory.getLogger(TitanGraphProvider.class); - - /** - * Constant for the configuration property that indicates the prefix. - */ - public static final String GRAPH_PREFIX = "atlas.graph"; - - public static final String INDEX_BACKEND_CONF = "index.search.backend"; - - public static final String INDEX_BACKEND_LUCENE = "lucene"; - - public static final String INDEX_BACKEND_ES = "elasticsearch"; - - private static volatile TitanGraph graphInstance; - - public static Configuration getConfiguration() throws AtlasException { - Configuration configProperties = ApplicationProperties.get(); - return ApplicationProperties.getSubsetConfiguration(configProperties, GRAPH_PREFIX); - } - - static { - addSolr5Index(); - } - - /** - * Titan loads index backend name to implementation using StandardIndexProvider.ALL_MANAGER_CLASSES - * But StandardIndexProvider.ALL_MANAGER_CLASSES is a private static final ImmutableMap - * Only way to inject Solr5Index is to modify this field. So, using hacky reflection to add Sol5Index + /* (non-Javadoc) + * @see org.apache.atlas.repository.graph.GraphProvider#get() */ - private static void addSolr5Index() { - try { - Field field = StandardIndexProvider.class.getDeclaredField("ALL_MANAGER_CLASSES"); - field.setAccessible(true); - - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - - Map<String, String> customMap = new HashMap(StandardIndexProvider.getAllProviderClasses()); - customMap.put("solr5", Solr5Index.class.getName()); - ImmutableMap<String, String> immap = ImmutableMap.copyOf(customMap); - field.set(null, immap); - - LOG.debug("Injected solr5 index - {}", Solr5Index.class.getName()); - } catch(Exception e) { - throw new RuntimeException(e); - } + @Override + public TitanGraph get() { + return Titan0Database.getGraphInstance(); } public static TitanGraph getGraphInstance() { - if (graphInstance == null) { - synchronized (TitanGraphProvider.class) { - if (graphInstance == null) { - Configuration config; - try { - config = getConfiguration(); - } catch (AtlasException e) { - throw new RuntimeException(e); - } - - graphInstance = TitanFactory.open(config); - validateIndexBackend(config); - } - } - } - return graphInstance; - } - - public static void clear() { - synchronized (TitanGraphProvider.class) { - graphInstance.shutdown(); - graphInstance = null; - } + return Titan0Database.getGraphInstance(); } - static void validateIndexBackend(Configuration config) { - String configuredIndexBackend = config.getString(INDEX_BACKEND_CONF); - - TitanManagement managementSystem = graphInstance.getManagementSystem(); - String currentIndexBackend = managementSystem.get(INDEX_BACKEND_CONF); - managementSystem.commit(); - - if(!configuredIndexBackend.equals(currentIndexBackend)) { - throw new RuntimeException("Configured Index Backend " + configuredIndexBackend + " differs from earlier configured Index Backend " + currentIndexBackend + ". Aborting!"); - } - + public static Configuration getConfiguration() throws AtlasException { + return Titan0Database.getConfiguration(); } - @Override - @Singleton - @Provides - public TitanGraph get() { - return getGraphInstance(); - } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/repository/src/main/scala/org/apache/atlas/query/TypeUtils.scala ---------------------------------------------------------------------- diff --git a/repository/src/main/scala/org/apache/atlas/query/TypeUtils.scala b/repository/src/main/scala/org/apache/atlas/query/TypeUtils.scala index ddcc106..dfa7093 100755 --- a/repository/src/main/scala/org/apache/atlas/query/TypeUtils.scala +++ b/repository/src/main/scala/org/apache/atlas/query/TypeUtils.scala @@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger import org.apache.atlas.AtlasException import org.apache.atlas.query.Expressions.{LimitExpression, PathExpression, SelectExpression} import org.apache.atlas.repository.Constants +import org.apache.atlas.repository.graph.GraphHelper import org.apache.atlas.typesystem.types.DataTypes.{ArrayType, PrimitiveType, TypeCategory} import org.apache.atlas.typesystem.types._ @@ -204,7 +205,7 @@ object TypeUtils { return Some(FieldInfo(typ,fMap.get.fields.get(id))) } - val systemField = Constants.getAttributeInfoForSystemAttributes(id) + val systemField = GraphHelper.getAttributeInfoForSystemAttributes(id) if (systemField != null) { return Some(FieldInfo(systemField.dataType(), systemField)) } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/repository/src/test/java/org/apache/atlas/repository/graph/TitanGraphProviderTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/TitanGraphProviderTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/TitanGraphProviderTest.java deleted file mode 100644 index 6fc7008..0000000 --- a/repository/src/test/java/org/apache/atlas/repository/graph/TitanGraphProviderTest.java +++ /dev/null @@ -1,78 +0,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. - */ -package org.apache.atlas.repository.graph; - -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.util.TitanCleanup; -import com.thinkaurelius.titan.diskstorage.Backend; -import com.thinkaurelius.titan.graphdb.database.StandardTitanGraph; -import org.apache.atlas.ApplicationProperties; -import org.apache.atlas.AtlasException; -import org.apache.commons.configuration.Configuration; -import org.mockito.Mockito; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -@Test -public class TitanGraphProviderTest { - - private Configuration configuration; - private TitanGraph graph; - - @BeforeTest - public void setUp() throws AtlasException { - //First get Instance - graph = TitanGraphProvider.getGraphInstance(); - configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(), TitanGraphProvider.GRAPH_PREFIX); - } - - @AfterClass - public void tearDown() throws Exception { - try { - graph.shutdown(); - } catch (Exception e) { - e.printStackTrace(); - } - - try { - TitanCleanup.clear(graph); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testValidate() throws AtlasException { - try { - TitanGraphProvider.validateIndexBackend(configuration); - } catch(Exception e){ - Assert.fail("Unexpected exception ", e); - } - - //Change backend - configuration.setProperty(TitanGraphProvider.INDEX_BACKEND_CONF, TitanGraphProvider.INDEX_BACKEND_LUCENE); - try { - TitanGraphProvider.validateIndexBackend(configuration); - Assert.fail("Expected exception"); - } catch(Exception e){ - Assert.assertEquals(e.getMessage(), "Configured Index Backend lucene differs from earlier configured Index Backend elasticsearch. Aborting!"); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/src/build/checkstyle-suppressions.xml ---------------------------------------------------------------------- diff --git a/src/build/checkstyle-suppressions.xml b/src/build/checkstyle-suppressions.xml index 0025360..bf16a9d 100644 --- a/src/build/checkstyle-suppressions.xml +++ b/src/build/checkstyle-suppressions.xml @@ -23,4 +23,7 @@ <suppressions> <suppress checks="JavadocType" files="[/\\]src[/\\]test[/\\]java[/\\]"/> + + <!-- skip checks on customized titan 0.5.4 files --> + <suppress checks="[a-zA-Z0-9]*" files="[/\\]com[/\\]thinkaurelius[/\\]titan[/\\]"/> </suppressions> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/titan/pom.xml ---------------------------------------------------------------------- diff --git a/titan/pom.xml b/titan/pom.xml deleted file mode 100644 index ae7894e..0000000 --- a/titan/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ -<?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> - <artifactId>apache-atlas</artifactId> - <groupId>org.apache.atlas</groupId> - <version>0.8-incubating-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>atlas-titan</artifactId> - <description>Apache Atlas Titan Overrides</description> - <name>Apache Atlas Titan</name> - <packaging>jar</packaging> - - <dependencies> - <dependency> - <groupId>com.thinkaurelius.titan</groupId> - <artifactId>titan-core</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.hbase</groupId> - <artifactId>hbase-client</artifactId> - </dependency> - - <dependency> - <groupId>com.vividsolutions</groupId> - <artifactId>jts</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.solr</groupId> - <artifactId>solr-core</artifactId> - <version>${solr.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.solr</groupId> - <artifactId>solr-solrj</artifactId> - <version>${solr.version}</version> - </dependency> - - <dependency> - <groupId>com.thinkaurelius.titan</groupId> - <artifactId>titan-es</artifactId> - </dependency> - - <dependency> - <groupId>com.thinkaurelius.titan</groupId> - <artifactId>titan-berkeleyje</artifactId> - </dependency> - - <dependency> - <groupId>com.thinkaurelius.titan</groupId> - <artifactId>titan-lucene</artifactId> - </dependency> - - <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - </dependency> - - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - </dependency> - - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.4</version> - <configuration> - <excludes> - <exclude>**/log4j.xml</exclude> - </excludes> - </configuration> - </plugin> - <plugin> - <groupId>net.alchim31.maven</groupId> - <artifactId>scala-maven-plugin</artifactId> - </plugin> - </plugins> - </build> - - -</project> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/AdminMask.java ---------------------------------------------------------------------- diff --git a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/AdminMask.java b/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/AdminMask.java deleted file mode 100644 index e255f1b..0000000 --- a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/AdminMask.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2012-2013 Aurelius LLC - * Licensed 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 com.thinkaurelius.titan.diskstorage.hbase; - -import java.io.Closeable; -import java.io.IOException; - -import org.apache.hadoop.hbase.ClusterStatus; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.TableNotFoundException; -import org.apache.hadoop.hbase.client.HBaseAdmin; - -/** - * This interface hides ABI/API breaking changes that HBase has made to its Admin/HBaseAdmin over the course - * of development from 0.94 to 1.0 and beyond. - */ -public interface AdminMask extends Closeable -{ - - void clearTable(String tableName, long timestamp) throws IOException; - - HTableDescriptor getTableDescriptor(String tableName) throws TableNotFoundException, IOException; - - boolean tableExists(String tableName) throws IOException; - - void createTable(HTableDescriptor desc) throws IOException; - - void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) throws IOException; - - /** - * Estimate the number of regionservers in the HBase cluster. - * - * This is usually implemented by calling - * {@link HBaseAdmin#getClusterStatus()} and then - * {@link ClusterStatus#getServers()} and finally {@code size()} on the - * returned server list. - * - * @return the number of servers in the cluster or -1 if it could not be determined - */ - int getEstimatedRegionServerCount(); - - void disableTable(String tableName) throws IOException; - - void enableTable(String tableName) throws IOException; - - boolean isTableDisabled(String tableName) throws IOException; - - void addColumn(String tableName, HColumnDescriptor columnDescriptor) throws IOException; -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/ConnectionMask.java ---------------------------------------------------------------------- diff --git a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/ConnectionMask.java b/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/ConnectionMask.java deleted file mode 100644 index feb578b..0000000 --- a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/ConnectionMask.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2013 Aurelius LLC - * Licensed 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 com.thinkaurelius.titan.diskstorage.hbase; - -import java.io.Closeable; -import java.io.IOException; - -/** - * This interface hides ABI/API breaking changes that HBase has made to its (H)Connection class over the course - * of development from 0.94 to 1.0 and beyond. - */ -public interface ConnectionMask extends Closeable -{ - - TableMask getTable(String name) throws IOException; - - AdminMask getAdmin() throws IOException; -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseAdmin0_98.java ---------------------------------------------------------------------- diff --git a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseAdmin0_98.java b/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseAdmin0_98.java deleted file mode 100644 index 0cd4795..0000000 --- a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseAdmin0_98.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2012-2013 Aurelius LLC - * Licensed 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 com.thinkaurelius.titan.diskstorage.hbase; - -import java.io.IOException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.thinkaurelius.titan.util.system.IOUtils; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.TableNotFoundException; -import org.apache.hadoop.hbase.client.Delete; -import org.apache.hadoop.hbase.client.HBaseAdmin; -import org.apache.hadoop.hbase.client.HTable; -import org.apache.hadoop.hbase.client.Result; -import org.apache.hadoop.hbase.client.ResultScanner; -import org.apache.hadoop.hbase.client.Scan; - -public class HBaseAdmin0_98 implements AdminMask -{ - - private static final Logger log = LoggerFactory.getLogger(HBaseAdmin0_98.class); - - private final HBaseAdmin adm; - - public HBaseAdmin0_98(HBaseAdmin adm) - { - this.adm = adm; - } - - @Override - public void clearTable(String tableName, long timestamp) throws IOException - { - if (!adm.tableExists(tableName)) { - log.debug("clearStorage() called before table {} was created, skipping.", tableName); - return; - } - - // Unfortunately, linear scanning and deleting tables is faster in HBase < 1 when running integration tests than - // disabling and deleting tables. - HTable table = null; - - try { - table = new HTable(adm.getConfiguration(), tableName); - - Scan scan = new Scan(); - scan.setBatch(100); - scan.setCacheBlocks(false); - scan.setCaching(2000); - scan.setTimeRange(0, Long.MAX_VALUE); - scan.setMaxVersions(1); - - ResultScanner scanner = null; - - try { - scanner = table.getScanner(scan); - - for (Result res : scanner) { - Delete d = new Delete(res.getRow()); - - d.setTimestamp(timestamp); - table.delete(d); - } - } finally { - IOUtils.closeQuietly(scanner); - } - } finally { - IOUtils.closeQuietly(table); - } - } - - @Override - public HTableDescriptor getTableDescriptor(String tableName) throws TableNotFoundException, IOException - { - return adm.getTableDescriptor(tableName.getBytes()); - } - - @Override - public boolean tableExists(String tableName) throws IOException - { - return adm.tableExists(tableName); - } - - @Override - public void createTable(HTableDescriptor desc) throws IOException - { - adm.createTable(desc); - } - - @Override - public void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) throws IOException - { - adm.createTable(desc, startKey, endKey, numRegions); - } - - @Override - public int getEstimatedRegionServerCount() - { - int serverCount = -1; - try { - serverCount = adm.getClusterStatus().getServers().size(); - log.debug("Read {} servers from HBase ClusterStatus", serverCount); - } catch (IOException e) { - log.debug("Unable to retrieve HBase cluster status", e); - } - return serverCount; - } - - @Override - public void disableTable(String tableName) throws IOException - { - adm.disableTable(tableName); - } - - @Override - public void enableTable(String tableName) throws IOException - { - adm.enableTable(tableName); - } - - @Override - public boolean isTableDisabled(String tableName) throws IOException - { - return adm.isTableDisabled(tableName); - } - - @Override - public void addColumn(String tableName, HColumnDescriptor columnDescriptor) throws IOException - { - adm.addColumn(tableName, columnDescriptor); - } - - @Override - public void close() throws IOException - { - adm.close(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseAdmin1_0.java ---------------------------------------------------------------------- diff --git a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseAdmin1_0.java b/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseAdmin1_0.java deleted file mode 100644 index 7e8f72d..0000000 --- a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseAdmin1_0.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2012-2013 Aurelius LLC - * Licensed 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 com.thinkaurelius.titan.diskstorage.hbase; - -import java.io.IOException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.TableNotDisabledException; -import org.apache.hadoop.hbase.TableNotFoundException; -import org.apache.hadoop.hbase.client.Admin; -import org.apache.hadoop.hbase.client.HBaseAdmin; - -public class HBaseAdmin1_0 implements AdminMask -{ - - private static final Logger log = LoggerFactory.getLogger(HBaseAdmin1_0.class); - - private final Admin adm; - - public HBaseAdmin1_0(HBaseAdmin adm) - { - this.adm = adm; - } - @Override - public void clearTable(String tableString, long timestamp) throws IOException - { - TableName tableName = TableName.valueOf(tableString); - - if (!adm.tableExists(tableName)) { - log.debug("Attempted to clear table {} before it exists (noop)", tableString); - return; - } - - if (!adm.isTableDisabled(tableName)) - adm.disableTable(tableName); - - if (!adm.isTableDisabled(tableName)) - throw new RuntimeException("Unable to disable table " + tableName); - - // This API call appears to both truncate and reenable the table. - log.info("Truncating table {}", tableName); - adm.truncateTable(tableName, true /* preserve splits */); - - try { - adm.enableTable(tableName); - } catch (TableNotDisabledException e) { - // This triggers seemingly every time in testing with 1.0.2. - log.debug("Table automatically reenabled by truncation: {}", tableName, e); - } - } - - @Override - public HTableDescriptor getTableDescriptor(String tableString) throws TableNotFoundException, IOException - { - return adm.getTableDescriptor(TableName.valueOf(tableString)); - } - - @Override - public boolean tableExists(String tableString) throws IOException - { - return adm.tableExists(TableName.valueOf(tableString)); - } - - @Override - public void createTable(HTableDescriptor desc) throws IOException - { - adm.createTable(desc); - } - - @Override - public void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) throws IOException - { - adm.createTable(desc, startKey, endKey, numRegions); - } - - @Override - public int getEstimatedRegionServerCount() - { - int serverCount = -1; - try { - serverCount = adm.getClusterStatus().getServers().size(); - log.debug("Read {} servers from HBase ClusterStatus", serverCount); - } catch (IOException e) { - log.debug("Unable to retrieve HBase cluster status", e); - } - return serverCount; - } - - @Override - public void disableTable(String tableString) throws IOException - { - adm.disableTable(TableName.valueOf(tableString)); - } - - @Override - public void enableTable(String tableString) throws IOException - { - adm.enableTable(TableName.valueOf(tableString)); - } - - @Override - public boolean isTableDisabled(String tableString) throws IOException - { - return adm.isTableDisabled(TableName.valueOf(tableString)); - } - - @Override - public void addColumn(String tableString, HColumnDescriptor columnDescriptor) throws IOException - { - adm.addColumn(TableName.valueOf(tableString), columnDescriptor); - } - - @Override - public void close() throws IOException - { - adm.close(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat.java ---------------------------------------------------------------------- diff --git a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat.java b/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat.java deleted file mode 100644 index c9b03aa..0000000 --- a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012-2013 Aurelius LLC - * Licensed 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 com.thinkaurelius.titan.diskstorage.hbase; - -import java.io.IOException; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.client.Delete; - -public interface HBaseCompat { - - /** - * Configure the compression scheme {@code algo} on a column family - * descriptor {@code cd}. The {@code algo} parameter is a string value - * corresponding to one of the values of HBase's Compression enum. The - * Compression enum has moved between packages as HBase has evolved, which - * is why this method has a String argument in the signature instead of the - * enum itself. - * - * @param cd - * column family to configure - * @param algo - * compression type to use - */ - public void setCompression(HColumnDescriptor cd, String algo); - - /** - * Create and return a HTableDescriptor instance with the given name. The - * constructors on this method have remained stable over HBase development - * so far, but the old HTableDescriptor(String) constructor & byte[] friends - * are now marked deprecated and may eventually be removed in favor of the - * HTableDescriptor(TableName) constructor. That constructor (and the - * TableName type) only exists in newer HBase versions. Hence this method. - * - * @param tableName - * HBase table name - * @return a new table descriptor instance - */ - public HTableDescriptor newTableDescriptor(String tableName); - - ConnectionMask createConnection(Configuration conf) throws IOException; - - void addColumnFamilyToTableDescriptor(HTableDescriptor tdesc, HColumnDescriptor cdesc); - - void setTimestamp(Delete d, long timestamp); -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat0_98.java ---------------------------------------------------------------------- diff --git a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat0_98.java b/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat0_98.java deleted file mode 100644 index 2c0f3b4..0000000 --- a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat0_98.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2012-2013 Aurelius LLC - * Licensed 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 com.thinkaurelius.titan.diskstorage.hbase; - -import java.io.IOException; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.Delete; -import org.apache.hadoop.hbase.client.HConnectionManager; -import org.apache.hadoop.hbase.io.compress.Compression; - -public class HBaseCompat0_98 implements HBaseCompat { - - @Override - public void setCompression(HColumnDescriptor cd, String algo) { - cd.setCompressionType(Compression.Algorithm.valueOf(algo)); - } - - @Override - public HTableDescriptor newTableDescriptor(String tableName) { - TableName tn = TableName.valueOf(tableName); - return new HTableDescriptor(tn); - } - - @Override - public ConnectionMask createConnection(Configuration conf) throws IOException - { - return new HConnection0_98(HConnectionManager.createConnection(conf)); - } - - @Override - public void addColumnFamilyToTableDescriptor(HTableDescriptor tdesc, HColumnDescriptor cdesc) - { - tdesc.addFamily(cdesc); - } - - @Override - public void setTimestamp(Delete d, long timestamp) - { - d.setTimestamp(timestamp); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat1_0.java ---------------------------------------------------------------------- diff --git a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat1_0.java b/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat1_0.java deleted file mode 100644 index bb3fb3b..0000000 --- a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat1_0.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2012-2013 Aurelius LLC - * Licensed 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 com.thinkaurelius.titan.diskstorage.hbase; - -import java.io.IOException; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.ConnectionFactory; -import org.apache.hadoop.hbase.client.Delete; -import org.apache.hadoop.hbase.io.compress.Compression; - -public class HBaseCompat1_0 implements HBaseCompat { - - @Override - public void setCompression(HColumnDescriptor cd, String algo) { - cd.setCompressionType(Compression.Algorithm.valueOf(algo)); - } - - @Override - public HTableDescriptor newTableDescriptor(String tableName) { - TableName tn = TableName.valueOf(tableName); - return new HTableDescriptor(tn); - } - - @Override - public ConnectionMask createConnection(Configuration conf) throws IOException - { - return new HConnection1_0(ConnectionFactory.createConnection(conf)); - } - - @Override - public void addColumnFamilyToTableDescriptor(HTableDescriptor tdesc, HColumnDescriptor cdesc) - { - tdesc.addFamily(cdesc); - } - - @Override - public void setTimestamp(Delete d, long timestamp) - { - d.setTimestamp(timestamp); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4fa10b6a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat1_1.java ---------------------------------------------------------------------- diff --git a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat1_1.java b/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat1_1.java deleted file mode 100644 index e5c3d31..0000000 --- a/titan/src/main/java/com/thinkaurelius/titan/diskstorage/hbase/HBaseCompat1_1.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2012-2013 Aurelius LLC - * Licensed 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 com.thinkaurelius.titan.diskstorage.hbase; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.ConnectionFactory; -import org.apache.hadoop.hbase.client.Delete; -import org.apache.hadoop.hbase.io.compress.Compression; - -import java.io.IOException; - -public class HBaseCompat1_1 implements HBaseCompat { - - @Override - public void setCompression(HColumnDescriptor cd, String algo) { - cd.setCompressionType(Compression.Algorithm.valueOf(algo)); - } - - @Override - public HTableDescriptor newTableDescriptor(String tableName) { - TableName tn = TableName.valueOf(tableName); - return new HTableDescriptor(tn); - } - - @Override - public ConnectionMask createConnection(Configuration conf) throws IOException - { - return new HConnection1_0(ConnectionFactory.createConnection(conf)); - } - - @Override - public void addColumnFamilyToTableDescriptor(HTableDescriptor tdesc, HColumnDescriptor cdesc) - { - tdesc.addFamily(cdesc); - } - - @Override - public void setTimestamp(Delete d, long timestamp) - { - d.setTimestamp(timestamp); - } - -}
