[1/2] atlas git commit: ATLAS-1836: fixed incorrect json in Area0 model
Repository: atlas Updated Branches: refs/heads/master 435fe3fba -> 6a1c4f4df ATLAS-1836: fixed incorrect json in Area0 model Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/41e5404f Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/41e5404f Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/41e5404f Branch: refs/heads/master Commit: 41e5404f96395c8fc3f1f8045ba921f283a49cce Parents: 435fe3f Author: Madhan Neethiraj Authored: Sun Nov 12 14:37:40 2017 -0800 Committer: Madhan Neethiraj Committed: Sun Nov 12 14:37:40 2017 -0800 -- addons/models/-Area0/0020-PropertyFacets_model.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/atlas/blob/41e5404f/addons/models/-Area0/0020-PropertyFacets_model.json -- diff --git a/addons/models/-Area0/0020-PropertyFacets_model.json b/addons/models/-Area0/0020-PropertyFacets_model.json index 0acdf48..fe92e26 100644 --- a/addons/models/-Area0/0020-PropertyFacets_model.json +++ b/addons/models/-Area0/0020-PropertyFacets_model.json @@ -70,7 +70,8 @@ "isIndexable": true, "isOptional": true, "isUnique": false -}, +} + ] } ] }
[2/2] atlas git commit: ATLAS-2251: fixed NPE in V1 to V2 entity conversion
ATLAS-2251: fixed NPE in V1 to V2 entity conversion Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/6a1c4f4d Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/6a1c4f4d Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/6a1c4f4d Branch: refs/heads/master Commit: 6a1c4f4df2b906673a8cedd6abbd20761fcfb183 Parents: 41e5404 Author: Madhan Neethiraj Authored: Sun Nov 12 14:39:13 2017 -0800 Committer: Madhan Neethiraj Committed: Sun Nov 12 14:39:13 2017 -0800 -- .../converters/AtlasEntityFormatConverter.java | 12 1 file changed, 8 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/atlas/blob/6a1c4f4d/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java -- diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java index a529dc1..2229ece 100644 --- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java +++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java @@ -66,10 +66,14 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter { entity.setGuid(entRef.getId().getId()); entity.setStatus(convertState(entRef.getId().getState())); - entity.setCreatedBy(entRef.getSystemAttributes().getCreatedBy()); - entity.setCreateTime(entRef.getSystemAttributes().getCreatedTime()); - entity.setUpdatedBy(entRef.getSystemAttributes().getModifiedBy()); - entity.setUpdateTime(entRef.getSystemAttributes().getModifiedTime()); + +if (entRef.getSystemAttributes() != null) { + entity.setCreatedBy(entRef.getSystemAttributes().getCreatedBy()); + entity.setCreateTime(entRef.getSystemAttributes().getCreatedTime()); + entity.setUpdatedBy(entRef.getSystemAttributes().getModifiedBy()); + entity.setUpdateTime(entRef.getSystemAttributes().getModifiedTime()); +} + entity.setVersion((long) entRef.getId().getVersion()); if (CollectionUtils.isNotEmpty(entRef.getTraitNames())) {
[26/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/scala/org/apache/atlas/query/Expressions.scala -- diff --git a/repository/src/main/scala/org/apache/atlas/query/Expressions.scala b/repository/src/main/scala/org/apache/atlas/query/Expressions.scala deleted file mode 100644 index bf9efd2..000 --- a/repository/src/main/scala/org/apache/atlas/query/Expressions.scala +++ /dev/null @@ -1,923 +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.query - -import com.google.common.collect.ImmutableCollection -import org.apache.atlas.AtlasException -import org.apache.atlas.typesystem.types.DataTypes.{ArrayType, PrimitiveType, TypeCategory} -import org.apache.atlas.typesystem.types._ -import scala.collection.JavaConverters._ - -object Expressions { - -import TypeUtils._ - -class ExpressionException(val e: Expression, message: String, cause: Throwable, enableSuppression: Boolean, - writableStackTrace: Boolean) -extends AtlasException(message, cause, enableSuppression, writableStackTrace) { - -def this(e: Expression, message: String) { -this(e, message, null, false, true) -} - -def this(e: Expression, message: String, cause: Throwable) { -this(e, message, cause, false, true) -} - -def this(e: Expression, cause: Throwable) { -this(e, null, cause, false, true) -} - -override def getMessage: String = { -val eString = e.toString -s"${super.getMessage}, expression:${if (eString contains "\n") "\n" else " "}$e" -} - -} - -class UnresolvedException(expr: Expression, function: String) extends -ExpressionException(expr, s"Unresolved $function") - -def attachExpression[A](e: Expression, msg: String = "")(f: => A): A = { -try f catch { -case eex: ExpressionException => throw eex -case ex: Exception => throw new ExpressionException(e, msg, ex) -} -} - -trait Expression { -self: Product => -def isAggregator = false -def children: Seq[Expression] - -/** - * Returns `true` if the schema for this expression and all its children have been resolved. - * The default logic is that an Expression is resolve if all its children are resolved. - */ -lazy val resolved: Boolean = childrenResolved - -/** - * Returns the output [[IDataType[_]] of this expression. Expressions that are unresolved will - * throw if this method is invoked. - */ -def dataType: IDataType[_] - -/** - * Returns true if all the children have been resolved. - */ -def childrenResolved = !children.exists(!_.resolved) - - -/** - * the aliases that are present in this Expression Tree - */ -def namedExpressions: Map[String, Expression] = Map() - -def fastEquals(other: Expression): Boolean = { -this.eq(other) || this == other -} - -def makeCopy(newArgs: Array[AnyRef]): this.type = attachExpression(this, "makeCopy") { -try { -val defaultCtor = getClass.getConstructors.find(_.getParameterTypes.size != 0).head -defaultCtor.newInstance(newArgs: _*).asInstanceOf[this.type] -} catch { -case e: java.lang.IllegalArgumentException => -throw new ExpressionException( -this, s"Failed to copy node. Reason: ${e.getMessage}.") -} -} - -def transformChildrenDown(rule: PartialFunction[Expression, Expression]): this.type = { -var changed = false -val newArgs = productIterator.map { -case arg: Expression if children contains arg => -val newChild = arg.asInstanceOf[Expression].transformDown(rule) -if (!(newChild fastEquals arg)) { -changed = true -newChild -} else { -
[11/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java -- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java deleted file mode 100755 index ba05a45..000 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java +++ /dev/null @@ -1,307 +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.typesystem.persistence; - -import com.google.common.collect.ImmutableList; -import org.apache.atlas.AtlasException; -import org.apache.atlas.utils.ParamChecker; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.types.FieldMapping; -import org.apache.atlas.utils.SHA256Utils; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.nio.charset.Charset; -import java.security.MessageDigest; -import java.util.Date; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicLong; - -public class Id implements ITypedReferenceableInstance { -public enum EntityState { -ACTIVE, DELETED -} - -public final String id; -public final String typeName; -public final int version; -public EntityState state; -private static AtomicLong s_nextId = new AtomicLong(System.nanoTime()); -public final AtlasSystemAttributes systemAttributes; - -public Id(String id, int version, String typeName, String state) { -id = ParamChecker.notEmpty(id, "id"); -typeName = ParamChecker.notEmpty(typeName, "typeName"); -state= ParamChecker.notEmptyIfNotNull(state, "state"); -this.id = id; -this.typeName = typeName; -this.version = version; -if (state == null) { -this.state = EntityState.ACTIVE; -} else { -this.state = EntityState.valueOf(state.toUpperCase()); -} -this.systemAttributes = new AtlasSystemAttributes(); -} - -public Id(String id, int version, String typeName) { -this(id, version, typeName, null); -} - -public Id(long id, int version, String typeName) { -this("" + id, version, typeName); -} - -public Id(long id, int version, String typeName, String state) { -this("" + id, version, typeName, state); -} - -public Id(String typeName) { -this("" + Id.nextNegativeLong(), 0, typeName); -} - -public boolean isUnassigned() { -try { -long l = Long.parseLong(id); -return l < 0; -} catch (NumberFormatException ne) { -return false; -} -} - -public boolean isAssigned() { -try { -UUID.fromString(id); -} catch (IllegalArgumentException e) { -return false; -} - -return true; -} - -@Override -public String toString() { -return String.format("(type: %s, id: %s)", typeName, isUnassigned() ? "" : "" + id); -} - -@Override -public String toShortString() { -return String.format("id[type=%s guid=%s state=%s]", typeName, id, state); -} - -@Override -public AtlasSystemAttributes getSystemAttributes(){ -return systemAttributes; -} - -public String getClassName() { -return typeName; -} - -public int getVersion() { -return version; -} - -public String _getId() { -return id; -} - -public EntityState getState() { -return state; -} - -public String getStateAsString() { -return state == null ? null : state.name(); -} - -@Override -public boolean equals(Object o) { -if (this == o) return true; -if (o == null || getClass() != o.getClass()) return false; -Id id1 = (Id) o; -return version == id1.version && -Objects.equals(id, id1.id) && -Objects.equals(typeName, id1.typeName) && -
[40/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java -- diff --git a/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java b/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java new file mode 100644 index 000..ea77a20 --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java @@ -0,0 +1,103 @@ +/** + * 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.model.notification; + +import org.apache.commons.lang.StringUtils; +import org.codehaus.jackson.annotate.JsonAutoDetect; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; + +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * Base type of hook message. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS) +@JsonIgnoreProperties(ignoreUnknown=true) +@XmlRootElement +@XmlAccessorType(XmlAccessType.PROPERTY) +public class HookNotification implements Serializable { +private static final long serialVersionUID = 1L; + +public static final String UNKNOW_USER = "UNKNOWN"; + +/** + * Type of the hook message. + */ +public enum HookNotificationType { +TYPE_CREATE, TYPE_UPDATE, ENTITY_CREATE, ENTITY_PARTIAL_UPDATE, ENTITY_FULL_UPDATE, ENTITY_DELETE +} + +protected HookNotificationType type; +protected String user; + +public HookNotification() { +} + +public HookNotification(HookNotificationType type, String user) { +this.type = type; +this.user = user; +} + +public HookNotificationType getType() { +return type; +} + +public void setType(HookNotificationType type) { +this.type = type; +} + +public String getUser() { +if (StringUtils.isEmpty(user)) { +return UNKNOW_USER; +} + +return user; +} + +public void setUser(String user) { +this.user = user; +} + +public void normalize() { } + +@Override +public String toString() { +return toString(new StringBuilder()).toString(); +} + +public StringBuilder toString(StringBuilder sb) { +if (sb == null) { +sb = new StringBuilder(); +} + +sb.append("HookNotification{"); +sb.append("type=").append(type); +sb.append(", user=").append(user); +sb.append("}"); + +return sb; +} +} http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/intg/src/main/java/org/apache/atlas/model/notification/MessageVersion.java -- diff --git a/intg/src/main/java/org/apache/atlas/model/notification/MessageVersion.java b/intg/src/main/java/org/apache/atlas/model/notification/MessageVersion.java new file mode 100644 index 000..1dafa94 --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/model/notification/MessageVersion.java @@ -0,0 +1,170 @@ +/** + * 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 ex
[08/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java -- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java deleted file mode 100644 index 0d86474..000 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java +++ /dev/null @@ -1,301 +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.typesystem.types.cache; - -import org.apache.atlas.AtlasException; -import org.apache.atlas.annotation.ConditionalOnAtlasProperty; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; -import org.apache.atlas.typesystem.types.EnumType; -import org.apache.atlas.typesystem.types.HierarchicalType; -import org.apache.atlas.typesystem.types.IDataType; -import org.apache.atlas.typesystem.types.StructType; -import org.apache.atlas.typesystem.types.TraitType; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import javax.inject.Singleton; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Caches the types in-memory within the same process space. - */ -@SuppressWarnings("rawtypes") -@Singleton -@Component -@ConditionalOnAtlasProperty(property = "atlas.TypeCache.impl", isDefault = true) -public class DefaultTypeCache implements TypeCache { -private static final Logger LOG = LoggerFactory.getLogger(DefaultTypeCache.class); - -private Map types_ = new ConcurrentHashMap<>(); -private static final List validTypeFilterCategories = -Arrays.asList(TypeCategory.CLASS, TypeCategory.TRAIT, TypeCategory.ENUM, TypeCategory.STRUCT); -private static final List validSupertypeFilterCategories = -Arrays.asList(TypeCategory.CLASS, TypeCategory.TRAIT); - -/* - * (non-Javadoc) - * @see - * org.apache.atlas.typesystem.types.cache.TypeCache#has(java.lang - * .String) - */ -@Override -public boolean has(String typeName) throws AtlasException { - -return types_.containsKey(typeName); -} - -/* (non-Javadoc) - * @see org.apache.atlas.typesystem.types.cache.TypeCache#has(org. - * apache.atlas.typesystem.types.DataTypes.TypeCategory, java.lang.String) - */ -@Override -public boolean has(TypeCategory typeCategory, String typeName) -throws AtlasException { - -assertValidTypeCategory(typeCategory); -return has(typeName); -} - -private void assertValidTypeCategory(String typeCategory) { -assertValidTypeCategory(TypeCategory.valueOf(typeCategory)); -} - -private void assertValidTypeCategory(TypeCategory typeCategory) { -// there might no need of 'typeCategory' in this implementation for -// certain API, but for a distributed cache, it might help for the -// implementers to partition the types per their category -// while persisting so that look can be efficient - -if (typeCategory == null) { -throw new IllegalArgumentException("Category of the types to be filtered is null."); -} - -if (!validTypeFilterCategories.contains(typeCategory)) { -throw new IllegalArgumentException("Category of the types should be one of " + -StringUtils.join(validTypeFilterCategories, ", ")); -} -} - -/* - * (non-Javadoc) - * @see - * org.apache.atlas.typesystem.types.cache.TypeCache#get(java.lang - * .String) - */ -@Override -public IDataType get(String typeName) throws AtlasException { - -return types_.get(typeName); -} - -/* (non-Javadoc) - * @see org.apache.atlas.typesystem.types.cache.TypeCache#get(org.ap
[36/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java -- diff --git a/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java b/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java index f313ddc..caa72ce 100644 --- a/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java +++ b/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java @@ -18,13 +18,15 @@ package org.apache.atlas.notification; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; import org.apache.atlas.kafka.AtlasKafkaMessage; +import org.apache.atlas.model.notification.AtlasNotificationMessage; +import org.apache.atlas.type.AtlasType; +import org.apache.atlas.model.notification.MessageVersion; +import org.codehaus.jackson.type.TypeReference; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.testng.annotations.Test; -import java.lang.reflect.Type; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -41,8 +43,6 @@ import org.apache.kafka.common.TopicPartition; */ public class AbstractNotificationConsumerTest { -private static final Gson GSON = new Gson(); - @Test public void testReceive() throws Exception { Logger logger = mock(Logger.class); @@ -54,27 +54,24 @@ public class AbstractNotificationConsumerTest { List jsonList = new LinkedList<>(); -jsonList.add(GSON.toJson(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage1))); -jsonList.add(GSON.toJson(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage2))); -jsonList.add(GSON.toJson(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage3))); -jsonList.add(GSON.toJson(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage4))); - -Type notificationMessageType = new TypeToken>(){}.getType(); +jsonList.add(AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage1))); +jsonList.add(AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage2))); +jsonList.add(AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage3))); +jsonList.add(AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage4))); -NotificationConsumer consumer = -new TestNotificationConsumer<>(notificationMessageType, jsonList, logger); +NotificationConsumer consumer = new TestNotificationConsumer(jsonList, logger); List> messageList = consumer.receive(); assertFalse(messageList.isEmpty()); -assertEquals(testMessage1, messageList.get(0).getMessage()); +assertEquals(messageList.get(0).getMessage(), testMessage1); -assertEquals(testMessage2, messageList.get(1).getMessage()); +assertEquals(messageList.get(1).getMessage(), testMessage2); -assertEquals(testMessage3, messageList.get(2).getMessage()); +assertEquals(messageList.get(2).getMessage(), testMessage3); -assertEquals(testMessage4, messageList.get(3).getMessage()); +assertEquals(messageList.get(3).getMessage(), testMessage4); } @Test @@ -88,20 +85,17 @@ public class AbstractNotificationConsumerTest { List jsonList = new LinkedList<>(); -String json1 = GSON.toJson(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage1)); -String json2 = GSON.toJson(new AtlasNotificationMessage<>(new MessageVersion("0.0.5"), testMessage2)); -String json3 = GSON.toJson(new AtlasNotificationMessage<>(new MessageVersion("0.5.0"), testMessage3)); -String json4 = GSON.toJson(testMessage4); +String json1 = AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), testMessage1)); +String json2 = AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("0.0.5"), testMessage2)); +String json3 = AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("0.5.0"), testMessage3)); +String json4 = AtlasType.toV1Json(testMessage4); jsonList.add(json1); jsonList.add(json2); jsonList.add(json3); jsonList.add(json4); -Type notificationMessageType = new TypeToken>(){}.getType(); - -NotificationConsumer consumer = -new TestNotificationConsumer<>(notificationMessageType, jsonList, logger); +NotificationConsumer consumer = new TestNotificationConsumer(jsonList, logger); List> messageList = consumer.receive(); @@ -124,16 +
[32/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java -- diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java index 1ce6168..a529dc1 100644 --- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java +++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEntityFormatConverter.java @@ -18,21 +18,20 @@ package org.apache.atlas.repository.converters; import org.apache.atlas.AtlasErrorCode; -import org.apache.atlas.AtlasException; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity.Status; import org.apache.atlas.model.instance.AtlasObjectId; +import org.apache.atlas.v1.model.instance.AtlasSystemAttributes; +import org.apache.atlas.v1.model.instance.Id; +import org.apache.atlas.v1.model.instance.Referenceable; +import org.apache.atlas.v1.model.instance.Struct; +import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasTypeRegistry; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.persistence.Id.EntityState; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -57,37 +56,29 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter { if (v1Obj != null) { AtlasEntityType entityType = (AtlasEntityType) type; -if (v1Obj instanceof IReferenceableInstance) { -IReferenceableInstance entRef = (IReferenceableInstance) v1Obj; +if (v1Obj instanceof Referenceable) { +Referenceable entRef = (Referenceable)v1Obj; -String guid = entRef.getId()._getId(); +String guid = entRef.getId().getId(); if (!context.entityExists(guid)) { -Map v1Attribs = null; +entity = new AtlasEntity(entRef.getTypeName(), super.fromV1ToV2(entityType, entRef.getValues(), context)); -try { -v1Attribs = entRef.getValuesMap(); -} catch (AtlasException excp) { -LOG.error("IReferenceableInstance.getValuesMap() failed", excp); -} - -entity = new AtlasEntity(entRef.getTypeName(), - super.fromV1ToV2(entityType, v1Attribs, context)); -entity.setGuid(entRef.getId()._getId()); +entity.setGuid(entRef.getId().getId()); entity.setStatus(convertState(entRef.getId().getState())); - entity.setCreatedBy(entRef.getSystemAttributes().createdBy); - entity.setCreateTime(entRef.getSystemAttributes().createdTime); - entity.setUpdatedBy(entRef.getSystemAttributes().modifiedBy); - entity.setUpdateTime(entRef.getSystemAttributes().modifiedTime); -entity.setVersion((long) entRef.getId().version); + entity.setCreatedBy(entRef.getSystemAttributes().getCreatedBy()); + entity.setCreateTime(entRef.getSystemAttributes().getCreatedTime()); + entity.setUpdatedBy(entRef.getSystemAttributes().getModifiedBy()); + entity.setUpdateTime(entRef.getSystemAttributes().getModifiedTime()); +entity.setVersion((long) entRef.getId().getVersion()); -if (CollectionUtils.isNotEmpty(entRef.getTraits())) { +if (CollectionUtils.isNotEmpty(entRef.getTraitNames())) { List classifications = new ArrayList<>(); -AtlasFormatConverter traitConverter = converterRegistry.getConverter(TypeCategory.CLASSIFICATION); +AtlasFormatConverter traitConverter = converterRegistry.getConverter(TypeCategory.CLASSIFICATION); -for (String traitName : entRef.getTraits()) { -IStruct trait = entRef.getTrait(traitName); -AtlasType classifiType = typeRegistry.getType(traitName); +
[07/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/src/main/scala/org/apache/atlas/typesystem/json/TypesSerialization.scala -- diff --git a/typesystem/src/main/scala/org/apache/atlas/typesystem/json/TypesSerialization.scala b/typesystem/src/main/scala/org/apache/atlas/typesystem/json/TypesSerialization.scala deleted file mode 100755 index 4478a44..000 --- a/typesystem/src/main/scala/org/apache/atlas/typesystem/json/TypesSerialization.scala +++ /dev/null @@ -1,270 +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.typesystem.json - -import java.text.SimpleDateFormat -import com.google.common.collect.ImmutableList -import org.apache.atlas.AtlasException -import org.apache.atlas.AtlasConstants -import org.apache.atlas.typesystem.TypesDef -import org.apache.atlas.typesystem.types.DataTypes.{ArrayType, MapType, TypeCategory} -import org.apache.atlas.typesystem.types._ -import org.json4s.JsonAST.JString -import org.json4s._ -import org.json4s.native.Serialization._ -import com.google.common.collect.ImmutableSet - - -/** - * Module for serializing to/from Json. - * - * @example {{{ - *val j = TypesSerialization.toJson(typeSystem, "Employee", "Person", "Department", "SecurityClearance") - * - *val typesDef = TypesSerialization.fromJson(jsonStr) - *typesDef.enumTypes.foreach( typeSystem.defineEnumType(_)) - - typeSystem.defineTypes(ImmutableList.copyOf(typesDef.structTypes.toArray), -ImmutableList.copyOf(typesDef.traitTypes.toArray), -ImmutableList.copyOf(typesDef.classTypes.toArray) - ) - * }}} - * - * @todo doesn't traverse includes directives. Includes are parsed into - * [[org.apache.atlas.tools.thrift.IncludeDef IncludeDef]] structures - * but are not traversed. - * @todo mixing in [[scala.util.parsing.combinator.PackratParsers PackratParsers]] is a placeholder. Need to - * change specific grammar rules to `lazy val` and `Parser[Elem]` to `PackratParser[Elem]`. Will do based on - * performance analysis. - * @todo Error reporting - */ -object TypesSerialization { - -def toJsonValue(typ: IDataType[_])(implicit formats: Formats): JValue = { -typ.getTypeCategory match { -case TypeCategory.CLASS => { - Extraction.decompose(convertClassTypeToHierarchicalTypeDefinition(typ.asInstanceOf[ClassType])) -} -case TypeCategory.STRUCT => { - Extraction.decompose(convertStructTypeToStructDef(typ.asInstanceOf[StructType])) -} -case TypeCategory.TRAIT => { - Extraction.decompose(convertTraitTypeToHierarchicalTypeDefinition(typ.asInstanceOf[TraitType])) -} -case TypeCategory.ENUM => { - Extraction.decompose(convertEnumTypeToEnumTypeDef(typ.asInstanceOf[EnumType])) -} -case _ => JString(s"${typ.getName}") -} -} - -def toJson(ts: TypeSystem, typName: String): String = { -toJson(ts, List(typName): _*) -} - -def toJson(ts: TypeSystem, typNames: String*): String = { -toJson(ts, (typ: IDataType[_]) => typNames.contains(typ.getName)) -} - -import scala.collection.JavaConversions._ - -def toJson(ts: TypeSystem, typNames: java.util.List[String]): String = { -toJson(ts, typNames.toIndexedSeq: _*) -} - -val _formats = new DefaultFormats { -override val dateFormatter = TypeSystem.getInstance().getDateFormat.asInstanceOf[SimpleDateFormat] -override val typeHints = NoTypeHints -} - -def toJson(ts: TypeSystem, export: IDataType[_] => Boolean): String = { -implicit val formats = _formats + new MultiplicitySerializer - -val typsDef = convertToTypesDef(ts, export) - -writePretty(typsDef) -} - -def fromJson(jsonStr: String): TypesDef = { -implicit val formats = _formats + new MultiplicitySerializer - -read[TypesDef](jsonStr) -} - -def toJson(typesDef : TypesDef) : String = { - implicit val formats = _formats + new MultiplicitySerializer - writePretty(ty
[20/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryDeleteTestBase.java -- diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryDeleteTestBase.java b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryDeleteTestBase.java deleted file mode 100644 index 0834601..000 --- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryDeleteTestBase.java +++ /dev/null @@ -1,1205 +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.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import org.apache.atlas.AtlasClient; -import org.apache.atlas.AtlasException; -import org.apache.atlas.CreateUpdateEntitiesResult; -import org.apache.atlas.RequestContext; -import org.apache.atlas.TestModules; -import org.apache.atlas.TestUtils; -import org.apache.atlas.model.legacy.EntityResult; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.MetadataRepository; -import org.apache.atlas.repository.RepositoryException; -import org.apache.atlas.repository.graphdb.AtlasGraph; -import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.ITypedStruct; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.TypesDef; -import org.apache.atlas.typesystem.exception.EntityExistsException; -import org.apache.atlas.typesystem.exception.EntityNotFoundException; -import org.apache.atlas.typesystem.exception.NullRequiredAttributeException; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.*; -import org.apache.atlas.typesystem.types.utils.TypesUtil; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.apache.atlas.TestUtils.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -/** - * Test for GraphBackedMetadataRepository.deleteEntities - * - * Guice loads the dependencies and injects the necessary objects - * - */ -@Guice(modules = TestModules.TestOnlyModule.class) -public abstract class GraphBackedMetadataRepositoryDeleteTestBase { - -protected MetadataRepository repositoryService; - -private TypeSystem typeSystem; - -private ClassType compositeMapOwnerType; - -private ClassType compositeMapValueType; - -@Inject -AtlasGraph atlasGraph; - -@BeforeClass -public void setUp() throws Exception { - -typeSystem = TypeSystem.getInstance(); -typeSystem.reset(); - -new GraphBackedSearchIndexer(new AtlasTypeRegistry()); -final GraphBackedMetadataRepository delegate = new GraphBackedMetadataRepository(getDeleteHandler(typeSystem), atlasGraph); - -repositoryService = TestUtils.addTransactionWrapper(delegate); - -TestUtils.defineDeptEmployeeTypes(typeSystem); -TestUtils.createHiveTypes(typeSystem); - -// Define type for map value. -HierarchicalTypeDefinition mapValueDef = TypesUtil.createClassTypeDef("CompositeMapValue", -ImmutableSet.of(), -TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE)); - -// Define type with map where the value is a composite class referen
[34/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/gremlin/GremlinExpressionFactory.java -- diff --git a/repository/src/main/java/org/apache/atlas/gremlin/GremlinExpressionFactory.java b/repository/src/main/java/org/apache/atlas/gremlin/GremlinExpressionFactory.java deleted file mode 100644 index d603150..000 --- a/repository/src/main/java/org/apache/atlas/gremlin/GremlinExpressionFactory.java +++ /dev/null @@ -1,658 +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_METHOD 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.gremlin; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.atlas.AtlasException; -import org.apache.atlas.groovy.AbstractFunctionExpression; -import org.apache.atlas.groovy.ArithmeticExpression; -import org.apache.atlas.groovy.ArithmeticExpression.ArithmeticOperator; -import org.apache.atlas.groovy.CastExpression; -import org.apache.atlas.groovy.ClosureExpression; -import org.apache.atlas.groovy.FieldExpression; -import org.apache.atlas.groovy.FunctionCallExpression; -import org.apache.atlas.groovy.GroovyExpression; -import org.apache.atlas.groovy.IdentifierExpression; -import org.apache.atlas.groovy.ListExpression; -import org.apache.atlas.groovy.LiteralExpression; -import org.apache.atlas.groovy.TraversalStepType; -import org.apache.atlas.groovy.TypeCoersionExpression; -import org.apache.atlas.groovy.VariableAssignmentExpression; -import org.apache.atlas.query.GraphPersistenceStrategies; -import org.apache.atlas.query.IntSequence; -import org.apache.atlas.query.TypeUtils.FieldInfo; -import org.apache.atlas.repository.graph.AtlasGraphProvider; -import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; -import org.apache.atlas.repository.graphdb.GremlinVersion; -import org.apache.atlas.typesystem.types.IDataType; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.apache.atlas.typesystem.types.cache.TypeCache.TYPE_FILTER; -import org.apache.atlas.util.AtlasRepositoryConfiguration; - -import com.google.common.collect.ImmutableList; - -/** - * Factory to generate Groovy expressions representing Gremlin syntax that that - * are independent of the specific version of Gremlin that is being used. - * - */ -public abstract class GremlinExpressionFactory { - -private static final String G_VARIABLE = "g"; -private static final String IT_VARIABLE = "it"; - -protected static final String SET_CLASS = "Set"; - - -private static final String OBJECT_FIELD = "object"; - -protected static final String V_METHOD = "V"; -protected static final String FILTER_METHOD = "filter"; -private static final String PATH_METHOD = "path"; -private static final String AS_METHOD = "as"; -private static final String IN_OPERATOR = "in"; -protected static final String HAS_METHOD = "has"; -protected static final String TO_LOWER_CASE_METHOD = "toLowerCase"; -protected static final String SELECT_METHOD = "select"; -protected static final String ORDER_METHOD = "order"; -protected static final String FILL_METHOD = "fill"; -protected static final String MATCHES = "matches"; - -public static final GremlinExpressionFactory INSTANCE = AtlasGraphProvider.getGraphInstance() -.getSupportedGremlinVersion() == GremlinVersion.THREE ? new Gremlin3ExpressionFactory() -: new Gremlin2ExpressionFactory(); - -/** - * Returns the unqualified name of the class used in this version of gremlin to - * represent Gremlin queries as they are being generated. - * @return - */ -public abstract String getTraversalExpressionClass(); - -/** - * Gets the expression to use as the parent when translating the loop - * expression in a loop - * - * @param inputQry - *the - * @return - */ -public abstract GroovyExpression getLoopExpressionParent(GroovyExpression inputQry); - -/** - * Generates a loop expression. - * - * @param parent - *the parent of the loop expression -
[33/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/gremlin/optimizer/GremlinQueryOptimizer.java -- diff --git a/repository/src/main/java/org/apache/atlas/gremlin/optimizer/GremlinQueryOptimizer.java b/repository/src/main/java/org/apache/atlas/gremlin/optimizer/GremlinQueryOptimizer.java deleted file mode 100644 index a0c08fd..000 --- a/repository/src/main/java/org/apache/atlas/gremlin/optimizer/GremlinQueryOptimizer.java +++ /dev/null @@ -1,262 +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.gremlin.optimizer; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.atlas.gremlin.GremlinExpressionFactory; -import org.apache.atlas.groovy.AbstractFunctionExpression; -import org.apache.atlas.groovy.GroovyExpression; -import org.apache.atlas.groovy.StatementListExpression; -import org.apache.atlas.groovy.TraversalStepType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.annotations.VisibleForTesting; - - - -/** - * Optimizer for gremlin queries. This class provides a framework for applying optimizations - * to gremlin queries. Each optimization is implemented as a class that implements {@link GremlinOptimization}. - * - * The GremlinQueryOptimizer is the entry point for applying these optimizations. - * - * - */ -public final class GremlinQueryOptimizer { - -private static final Logger LOGGER = LoggerFactory.getLogger(GremlinQueryOptimizer.class); - - -private final List optimizations = new ArrayList<>(); - -//Allows expression factory to be substituted in unit tests. -private static volatile GremlinExpressionFactory FACTORY = GremlinExpressionFactory.INSTANCE; - -private static volatile GremlinQueryOptimizer INSTANCE = null; - -private GremlinQueryOptimizer() { - -} - -private void addOptimization(GremlinOptimization opt) { -optimizations.add(opt); -} - -public static GremlinQueryOptimizer getInstance() { -if(INSTANCE == null) { -synchronized(GremlinQueryOptimizer.class) { -if(INSTANCE == null) { -GremlinQueryOptimizer createdInstance = new GremlinQueryOptimizer(); -//The order here is important. If there is an "or" nested within an "and", -//that will not be found if ExpandOrsOptimization runs before ExpandAndsOptimization. -createdInstance.addOptimization(new ExpandAndsOptimization(FACTORY)); -createdInstance.addOptimization(new ExpandOrsOptimization(FACTORY)); -INSTANCE = createdInstance; -} -} -} -return INSTANCE; -} - -/** - * For testing only - */ -@VisibleForTesting -public static void setExpressionFactory(GremlinExpressionFactory factory) { -GremlinQueryOptimizer.FACTORY = factory; -} - -/** - * For testing only - */ -@VisibleForTesting -public static void reset() { -INSTANCE = null; -} - -/** - * Optimizes the provided groovy expression. Note that the optimization - * is a destructive process. The source GroovyExpression will be - * modified as part of the optimization process. This is done to avoid - * expensive copying operations where possible. - * - * @param source what to optimize - * @return the optimized query - */ -public GroovyExpression optimize(GroovyExpression source) { -LOGGER.debug("Optimizing gremlin query: " + source); -OptimizationContext context = new OptimizationContext(); -GroovyExpression updatedExpression = source; -for (GremlinOptimization opt : optimizations) { -updatedExpression = optimize(updatedExpression, opt, context); -LOGGER.debug("After "+ opt.getClass().getSimpleName() + ", query = " + updatedExpression); -} - -StatementListExpression result = new StatementListExpression(); -result.addStatements(context.getInitialStatements()); -result.addSt
[24/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/BaseRepositoryTest.java -- diff --git a/repository/src/test/java/org/apache/atlas/BaseRepositoryTest.java b/repository/src/test/java/org/apache/atlas/BaseRepositoryTest.java deleted file mode 100644 index 7c6b60b..000 --- a/repository/src/test/java/org/apache/atlas/BaseRepositoryTest.java +++ /dev/null @@ -1,428 +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; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import org.apache.atlas.repository.MetadataRepository; -import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; -import org.apache.atlas.services.MetadataService; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.TypesDef; -import org.apache.atlas.typesystem.json.TypesSerialization; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.*; -import org.apache.atlas.typesystem.types.utils.TypesUtil; -import org.testng.annotations.Guice; - -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import static org.apache.atlas.AtlasClient.PROCESS_ATTRIBUTE_INPUTS; -import static org.apache.atlas.AtlasClient.PROCESS_ATTRIBUTE_OUTPUTS; - -/** - * Base Class to set up hive types and instances for tests - */ -@Guice(modules = TestModules.TestOnlyModule.class) -public class BaseRepositoryTest { - -@Inject -protected MetadataService metadataService; - -@Inject -protected MetadataRepository repository; - - -protected void setUp() throws Exception { -//force graph initialization / built in type registration -TestUtils.getGraph(); -setUpDefaultTypes(); -setUpTypes(); -TestUtils.getGraph().commit(); -new GraphBackedSearchIndexer(new AtlasTypeRegistry()); -TestUtils.resetRequestContext(); -setupInstances(); -TestUtils.getGraph().commit(); -TestUtils.dumpGraph(TestUtils.getGraph()); -} - -protected void tearDown() throws Exception { -TypeSystem.getInstance().reset(); -} - -private void setUpTypes() throws Exception { -TypesDef typesDef = createTypeDefinitions(); -String typesAsJSON = TypesSerialization.toJson(typesDef); -metadataService.createType(typesAsJSON); -} - -protected static final String DATABASE_TYPE = "hive_db"; -protected static final String HIVE_TABLE_TYPE = "hive_table"; -private static final String COLUMN_TYPE = "hive_column"; -private static final String HIVE_PROCESS_TYPE = "hive_process"; -private static final String STORAGE_DESC_TYPE = "StorageDesc"; -private static final String VIEW_TYPE = "View"; -private static final String PARTITION_TYPE = "hive_partition"; -protected static final String DATASET_SUBTYPE = "dataset_subtype"; - -TypesDef createTypeDefinitions() { -HierarchicalTypeDefinition dbClsDef = TypesUtil -.createClassTypeDef(DATABASE_TYPE, null, -TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), -attrDef("description", DataTypes.STRING_TYPE), attrDef("locationUri", DataTypes.STRING_TYPE), -attrDef("owner", DataTypes.STRING_TYPE), attrDef("createTime", DataTypes.LONG_TYPE)); - -HierarchicalTypeDefinition columnClsDef = TypesUtil -.createClassTypeDef(COLUMN_TYPE, null, attrDef("name", DataTypes.STRING_TYPE), -attrDef("dataType", DataTypes.STRING_TYPE), attrDef("comment", DataTypes.STRING_TYPE)); - -HierarchicalTypeDefinition storageDescClsDef = TypesUtil -.createClassTypeDef(STORAGE_DESC_TYPE, null, -attrDef("location", DataTypes.STRING_TYPE), -attrDef("inputFormat", DataTypes.STRING_TYPE), attrDef("outputFormat", DataTyp
[30/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/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 ffe859b..3e60243 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 @@ -24,12 +24,15 @@ import com.google.common.collect.HashBiMap; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasException; -import org.apache.atlas.RequestContext; +import org.apache.atlas.RequestContextV1; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity.Status; import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasRelationship; import org.apache.atlas.model.typedef.AtlasRelationshipDef; +import org.apache.atlas.v1.model.instance.Id; +import org.apache.atlas.v1.model.instance.Referenceable; +import org.apache.atlas.type.AtlasStructType.AtlasAttribute; import org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection; import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.RepositoryException; @@ -43,31 +46,11 @@ import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasRelationshipType; import org.apache.atlas.type.AtlasType; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.ITypedInstance; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.exception.EntityNotFoundException; -import org.apache.atlas.typesystem.exception.TypeNotFoundException; -import org.apache.atlas.typesystem.json.InstanceSerialization; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.persistence.ReferenceableInstance; -import org.apache.atlas.typesystem.types.AttributeInfo; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.DataTypes; -import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; -import org.apache.atlas.typesystem.types.HierarchicalType; -import org.apache.atlas.typesystem.types.IDataType; -import org.apache.atlas.typesystem.types.Multiplicity; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.apache.atlas.typesystem.types.ValueConversionException; -import org.apache.atlas.typesystem.types.utils.TypesUtil; +import org.apache.atlas.exception.EntityNotFoundException; import org.apache.atlas.util.AttributeValueMap; import org.apache.atlas.util.IndexedInstance; -import org.apache.atlas.utils.ParamChecker; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.codehaus.jettison.json.JSONArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -82,7 +65,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.Stack; import java.util.UUID; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.BOTH; @@ -97,8 +79,6 @@ public final class GraphHelper { private static final Logger LOG = LoggerFactory.getLogger(GraphHelper.class); public static final String EDGE_LABEL_PREFIX = "__"; -private static final TypeSystem typeSystem = TypeSystem.getInstance(); - public static final String RETRY_COUNT = "atlas.graph.storage.num.retries"; public static final String RETRY_DELAY = "atlas.graph.storage.retry.sleeptime.ms"; @@ -143,7 +123,7 @@ public final class GraphHelper { } -public AtlasVertex createVertexWithIdentity(ITypedReferenceableInstance typedInstance, Set superTypeNames) { +public AtlasVertex createVertexWithIdentity(Referenceable typedInstance, Set superTypeNames) { final String guid = UUID.randomUUID().toString(); final AtlasVertex vertexWithIdentity = createVertexWithoutIdentity(typedInstance.getTypeName(), @@ -153,7 +133,7 @@ public final class GraphHelper { setProperty(vertexWithIdentity, Constants.GUID_PROPERTY_KEY, guid); // add version information -setProperty(vertexWithIdentity, Constants.VERSION_PROPERTY_KEY, Long.valueOf(typedInstance.getId().version)); +setProperty(vertexWithIdentity, Constants.VERSION_PROPERTY_KEY, Long.valueOf(typedInstance.getId().getVersion())); return vertexWithIdentity; } @@ -179,12 +159,12 @@ public final class GraphHelper { setProperty(vertexWithoutIdentity, C
[41/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java -- diff --git a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java index f7404ae..773a1e8 100755 --- a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java +++ b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java @@ -19,18 +19,16 @@ package org.apache.atlas.hive.hook; import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; import com.sun.jersey.api.client.ClientResponse; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasServiceException; import org.apache.atlas.hive.HiveITBase; import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; import org.apache.atlas.hive.model.HiveDataTypes; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.atlas.model.typedef.AtlasBaseTypeDef; +import org.apache.atlas.v1.model.instance.Id; +import org.apache.atlas.v1.model.instance.Struct; +import org.apache.atlas.v1.model.instance.Referenceable; import org.apache.commons.lang.StringUtils; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hive.metastore.TableType; @@ -182,7 +180,7 @@ public class HiveHookIT extends HiveITBase { private void verifyTimestamps(Referenceable ref, String property, long expectedTime) throws ParseException { //Verify timestamps. String createTimeStr = (String) ref.get(property); -Date createDate = TypeSystem.getInstance().getDateFormat().parse(createTimeStr); +Date createDate = AtlasBaseTypeDef.DATE_FORMATTER.parse(createTimeStr); Assert.assertNotNull(createTimeStr); if (expectedTime > 0) { @@ -1262,7 +1260,7 @@ public class HiveHookIT extends HiveITBase { String guid2 = assertColumnIsRegistered(HiveMetaStoreBridge.getColumnQualifiedName(tbqn, "id_new")); assertEquals(guid2, guid); -assertTrue(atlasClient.getEntity(guid2).getTraits().contains(trait)); + assertTrue(atlasClient.getEntity(guid2).getTraitNames().contains(trait)); } @Test @@ -1349,15 +1347,15 @@ public class HiveHookIT extends HiveITBase { @Test public void testAlterTableBucketingClusterSort() throws Exception { String tableName = createTable(); -ImmutableList cols = ImmutableList.of("id"); +List cols = Collections.singletonList("id"); runBucketSortQuery(tableName, 5, cols, cols); -cols = ImmutableList.of("id", NAME); +cols = Arrays.asList("id", NAME); runBucketSortQuery(tableName, 2, cols, cols); } -private void runBucketSortQuery(String tableName, final int numBuckets, final ImmutableList bucketCols, -final ImmutableList sortCols) throws Exception { +private void runBucketSortQuery(String tableName, final int numBuckets, final List bucketCols, +final List sortCols) throws Exception { final String fmtQuery = "alter table %s CLUSTERED BY (%s) SORTED BY (%s) INTO %s BUCKETS"; String query = String.format(fmtQuery, tableName, stripListBrackets(bucketCols.toString()), stripListBrackets(sortCols.toString()), numBuckets); @@ -1375,8 +1373,8 @@ public class HiveHookIT extends HiveITBase { } private void verifyBucketSortingProperties(Referenceable tableRef, int numBuckets, - ImmutableList bucketColNames, - ImmutableList sortcolNames) throws Exception { + List bucketColNames, + List sortcolNames) throws Exception { Referenceable sdRef = (Referenceable) tableRef.get(HiveMetaStoreBridge.STORAGE_DESC); Assert.assertEquals(((scala.math.BigInt) sdRef.get(HiveMetaStoreBridge.STORAGE_NUM_BUCKETS)).intValue(), numBuckets); http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/addons/sqoop-bridge/pom.xml -- diff --git a/addons/sqoop-bridge/pom.xml b/addons/sqoop-bridge/pom.xml index d46d8a9..5a9305e 100644 --- a/addons/sqoop-bridge/pom.xml +++ b/addons/sqoop-bridge/pom.xml @@ -94,11 +94,6 @@ compile - -org.apache.atlas -atlas-typesystem - - org.apache.atlas atlas-client-v1 @@ -155,13 +150,6 @@ pom
[15/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java -- diff --git a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java deleted file mode 100644 index e885b8c..000 --- a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java +++ /dev/null @@ -1,1381 +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.service; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Inject; -import org.apache.atlas.AtlasClient; -import org.apache.atlas.AtlasException; -import org.apache.atlas.CreateUpdateEntitiesResult; -import org.apache.atlas.EntityAuditEvent; -import org.apache.atlas.RequestContext; -import org.apache.atlas.TestModules; -import org.apache.atlas.TestUtils; -import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService; -import org.apache.atlas.exception.AtlasBaseException; -import org.apache.atlas.listener.ChangedTypeDefs; -import org.apache.atlas.listener.EntityChangeListener; -import org.apache.atlas.listener.TypeDefChangeListener; -import org.apache.atlas.model.legacy.EntityResult; -import org.apache.atlas.query.QueryParams; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.audit.EntityAuditRepository; -import org.apache.atlas.repository.audit.HBaseBasedAuditRepository; -import org.apache.atlas.repository.audit.HBaseTestUtils; -import org.apache.atlas.repository.graph.AtlasGraphProvider; -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.AtlasVertex; -import org.apache.atlas.services.DefaultMetadataService; -import org.apache.atlas.services.MetadataService; -import org.apache.atlas.type.AtlasTypeUtil; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.TypesDef; -import org.apache.atlas.typesystem.exception.EntityNotFoundException; -import org.apache.atlas.typesystem.exception.TypeNotFoundException; -import org.apache.atlas.typesystem.json.InstanceSerialization; -import org.apache.atlas.typesystem.json.TypesSerialization; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.AttributeDefinition; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.DataTypes; -import org.apache.atlas.typesystem.types.EnumValue; -import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition; -import org.apache.atlas.typesystem.types.Multiplicity; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.apache.atlas.typesystem.types.ValueConversionException; -import org.apache.atlas.typesystem.types.cache.TypeCache; -import org.apache.atlas.typesystem.types.utils.TypesUtil; -import org.apache.atlas.utils.ParamChecker; -import org.codehaus.jettison.json.JSONArray; -import org.codehaus.jettison.json.JSONException; -import org.codehaus.jettison.json.JSONObject; -import org.testng.Assert; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import static org.apache.atlas.TestUtils.*; -import static org.apache.atlas.typesys
[42/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/435fe3fb Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/435fe3fb Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/435fe3fb Branch: refs/heads/master Commit: 435fe3fbad0dbb41297cc7af7986d3062704d7ee Parents: 0abf84c Author: Madhan Neethiraj Authored: Fri Nov 3 22:45:05 2017 -0700 Committer: Madhan Neethiraj Committed: Sun Nov 12 10:08:25 2017 -0800 -- addons/falcon-bridge/pom.xml| 61 +- .../atlas/falcon/bridge/FalconBridge.java |4 +- .../apache/atlas/falcon/hook/FalconHook.java|9 +- .../apache/atlas/falcon/hook/FalconHookIT.java | 20 +- addons/hbase-bridge/pom.xml | 97 +- .../atlas/hbase/bridge/HBaseAtlasHook.java | 47 +- .../hbase/model/HBaseOperationContext.java |8 +- .../apache/atlas/hbase/HBaseAtlasHookIT.java|2 +- addons/hdfs-model/pom.xml | 66 - addons/hive-bridge/pom.xml | 56 +- .../atlas/hive/bridge/ColumnLineageUtils.java |2 +- .../atlas/hive/bridge/HiveMetaStoreBridge.java | 18 +- .../org/apache/atlas/hive/hook/HiveHook.java| 29 +- .../java/org/apache/atlas/hive/HiveITBase.java |4 +- .../hive/bridge/HiveMetaStoreBridgeTest.java|4 +- .../hive/bridge/HiveMetastoreBridgeIT.java |8 +- .../org/apache/atlas/hive/hook/HiveHookIT.java | 26 +- addons/sqoop-bridge/pom.xml | 61 +- .../org/apache/atlas/sqoop/hook/SqoopHook.java |9 +- addons/storm-bridge/pom.xml | 115 +- .../apache/atlas/storm/hook/StormAtlasHook.java |2 +- .../atlas/storm/hook/StormAtlasHookIT.java |2 +- authorization/pom.xml |7 + client/client-v1/pom.xml|9 +- .../main/java/org/apache/atlas/AtlasClient.java | 54 +- .../java/org/apache/atlas/EntityAuditEvent.java | 19 +- .../src/main/java/org/apache/atlas/SerDe.java | 80 - .../java/org/apache/atlas/AtlasClientTest.java |6 +- client/pom.xml | 12 +- common/pom.xml |1 + .../org/apache/atlas/AtlasConfiguration.java| 83 -- .../org/apache/atlas/repository/Constants.java |7 + graphdb/api/pom.xml |6 +- .../atlas/repository/graphdb/AtlasGraph.java| 12 +- graphdb/common/pom.xml |6 + .../graphdb/janus/AtlasJanusGraph.java |6 +- .../repository/graphdb/titan0/Titan0Graph.java |6 +- .../repository/graphdb/titan1/Titan1Graph.java |6 +- intg/pom.xml| 26 +- .../org/apache/atlas/AtlasConfiguration.java| 83 ++ .../AtlasNotificationBaseMessage.java | 208 +++ .../notification/AtlasNotificationMessage.java | 101 ++ .../AtlasNotificationStringMessage.java | 82 ++ .../model/notification/EntityNotification.java | 86 ++ .../model/notification/HookNotification.java| 103 ++ .../model/notification/MessageVersion.java | 170 +++ .../java/org/apache/atlas/type/AtlasType.java | 167 ++- .../apache/atlas/type/AtlasTypeRegistry.java|4 +- .../org/apache/atlas/type/AtlasTypeUtil.java| 157 +- .../atlas/typesystem/types/DataTypes.java | 35 + .../model/instance/AtlasSystemAttributes.java | 156 ++ .../org/apache/atlas/v1/model/instance/Id.java | 270 .../atlas/v1/model/instance/Referenceable.java | 252 .../apache/atlas/v1/model/instance/Struct.java | 211 +++ .../model/lineage/DataSetLineageResponse.java | 65 + .../atlas/v1/model/lineage/LineageResponse.java | 75 + .../atlas/v1/model/lineage/SchemaResponse.java | 116 ++ .../notification/EntityNotificationV1.java | 231 +++ .../model/notification/HookNotificationV1.java | 357 + .../v1/model/typedef/AttributeDefinition.java | 179 +++ .../v1/model/typedef/ClassTypeDefinition.java | 57 + .../v1/model/typedef/EnumTypeDefinition.java| 174 +++ .../typedef/HierarchicalTypeDefinition.java | 96 ++ .../atlas/v1/model/typedef/Multiplicity.java| 167 +++ .../v1/model/typedef/StructTypeDefinition.java | 119 ++ .../v1/model/typedef/TraitTypeDefinition.java | 51 + .../apache/atlas/v1/model/typedef/TypesDef.java | 118 ++ .../v1/typesystem/types/utils/TypesUtil.java| 112 ++ .../apache/atlas/TestRelationshipUtilsV2.java | 26 +- .../test/java/org/apache/atlas/TestUtilsV2.java | 144 +- .../atlas/type/TestAtlasRelationshipType.java | 14 +- .../test/resources/atlas-application.properties | 145 ++ intg/src/test/resources/policy-store.txt|9 + intg/src/tes
[17/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java -- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java deleted file mode 100644 index 718538a..000 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java +++ /dev/null @@ -1,1141 +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.store.graph.v1; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import org.apache.atlas.AtlasException; -import org.apache.atlas.RequestContextV1; -import org.apache.atlas.TestUtils; -import org.apache.atlas.TestUtilsV2; -import org.apache.atlas.exception.AtlasBaseException; -import org.apache.atlas.model.instance.AtlasEntity; -import org.apache.atlas.model.instance.AtlasEntityHeader; -import org.apache.atlas.model.instance.AtlasObjectId; -import org.apache.atlas.model.instance.AtlasStruct; -import org.apache.atlas.model.instance.EntityMutationResponse; -import org.apache.atlas.model.instance.EntityMutations; -import org.apache.atlas.model.typedef.AtlasClassificationDef; -import org.apache.atlas.model.typedef.AtlasEntityDef; -import org.apache.atlas.model.typedef.AtlasEnumDef; -import org.apache.atlas.model.typedef.AtlasStructDef; -import org.apache.atlas.model.typedef.AtlasTypesDef; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.graph.AtlasEdgeLabel; -import org.apache.atlas.repository.graph.AtlasGraphProvider; -import org.apache.atlas.repository.graph.GraphHelper; -import org.apache.atlas.repository.graphdb.AtlasGraph; -import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; -import org.apache.atlas.repository.store.graph.AtlasEntityStore; -import org.apache.atlas.services.MetadataService; -import org.apache.atlas.store.AtlasTypeDefStore; -import org.apache.atlas.type.AtlasEntityType; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.apache.atlas.type.AtlasTypeUtil; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.ITypedStruct; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.exception.EntityNotFoundException; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.Multiplicity; -import org.apache.atlas.typesystem.types.TraitType; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.apache.atlas.TestUtils.*; -import static org.mockito.Mockito.mock; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -public abstract class AtlasDeleteHandlerV1Test { - -@Inject -AtlasTypeRegistry typeRegistry; - -@Inject -AtlasTypeDefStore typeDefStore; - -@Inject -AtlasEntityStore entityStore; - -@Inject -MetadataService metadataService; - -private AtlasEntityType compositeMapOwnerType; - -private AtlasEntityType compositeMapValueType; - -private TypeSystem typeSystem = TypeSystem.getInstance(); - -@BeforeClass -public void setUp() throws Exception { -RequestContextV1.clear(); -RequestContextV1.get().setUser(TestUtilsV2.TEST_USER); - -metadataService = TestUtils
[16/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java -- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java index 6475639..2c21638 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java @@ -20,7 +20,6 @@ package org.apache.atlas.repository.store.graph.v1; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.apache.atlas.RequestContextV1; -import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; @@ -32,7 +31,6 @@ import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.graph.AtlasEntityStore; -import org.apache.atlas.services.MetadataService; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasTypeRegistry; @@ -48,11 +46,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.apache.atlas.TestUtils.NAME; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; +import static org.apache.atlas.TestUtilsV2.NAME; + /** * Test automatic inverse reference updating in V1 (V2?) code path. * @@ -67,9 +66,6 @@ public abstract class InverseReferenceUpdateV1Test { @Inject AtlasEntityStore entityStore; -@Inject -MetadataService metadataService; - private AtlasEntitiesWithExtInfo deptEntity; protected Map nameIdMap = new HashMap<>(); @@ -79,8 +75,6 @@ public abstract class InverseReferenceUpdateV1Test { RequestContextV1.clear(); RequestContextV1.get().setUser(TestUtilsV2.TEST_USER); -metadataService = TestUtils.addSessionCleanupWrapper(metadataService); - AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), TestUtilsV2.defineInverseReferenceTestTypes() }; @@ -147,14 +141,14 @@ public abstract class InverseReferenceUpdateV1Test { public void testInverseReferenceAutoUpdate_NonCompositeManyToOne() throws Exception { AtlasEntityType bType = typeRegistry.getEntityTypeByName("B"); AtlasEntity a1 = new AtlasEntity("A"); -a1.setAttribute(NAME, TestUtils.randomString()); +a1.setAttribute(NAME, TestUtilsV2.randomString()); AtlasEntity a2 = new AtlasEntity("A"); -a2.setAttribute(NAME, TestUtils.randomString()); +a2.setAttribute(NAME, TestUtilsV2.randomString()); AtlasEntity a3 = new AtlasEntity("A"); -a3.setAttribute(NAME, TestUtils.randomString()); +a3.setAttribute(NAME, TestUtilsV2.randomString()); AtlasEntity b = new AtlasEntity("B"); -b.setAttribute(NAME, TestUtils.randomString()); +b.setAttribute(NAME, TestUtilsV2.randomString()); AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo = new AtlasEntitiesWithExtInfo(); atlasEntitiesWithExtInfo.addEntity(a1); atlasEntitiesWithExtInfo.addEntity(a2); @@ -208,11 +202,11 @@ public abstract class InverseReferenceUpdateV1Test { public void testInverseReferenceAutoUpdate_NonComposite_OneToOne() throws Exception { AtlasEntityType bType = typeRegistry.getEntityTypeByName("B"); AtlasEntity a1 = new AtlasEntity("A"); -a1.setAttribute(NAME, TestUtils.randomString()); +a1.setAttribute(NAME, TestUtilsV2.randomString()); AtlasEntity a2 = new AtlasEntity("A"); -a2.setAttribute(NAME, TestUtils.randomString()); +a2.setAttribute(NAME, TestUtilsV2.randomString()); AtlasEntity b = new AtlasEntity("B"); -b.setAttribute(NAME, TestUtils.randomString()); +b.setAttribute(NAME, TestUtilsV2.randomString()); AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo = new AtlasEntitiesWithExtInfo(); atlasEntitiesWithExtInfo.addEntity(a1); atlasEntitiesWithExtInfo.addEntity(a2); @@ -261,15 +255,15 @@ public abstract class InverseReferenceUpdateV1Test { public void testInverseReferenceAutoUpdate_NonComposite_ManyToMany() throws Exception
[25/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/scala/org/apache/atlas/query/GremlinQuery.scala -- diff --git a/repository/src/main/scala/org/apache/atlas/query/GremlinQuery.scala b/repository/src/main/scala/org/apache/atlas/query/GremlinQuery.scala deleted file mode 100644 index 37015d8..000 --- a/repository/src/main/scala/org/apache/atlas/query/GremlinQuery.scala +++ /dev/null @@ -1,806 +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.query - -import java.lang.Boolean -import java.lang.Byte -import java.lang.Double -import java.lang.Float -import java.lang.Integer -import java.lang.Long -import java.lang.Short -import java.util.ArrayList - -import scala.collection.JavaConversions.asScalaBuffer -import scala.collection.JavaConversions.bufferAsJavaList -import scala.collection.mutable -import scala.collection.mutable.ArrayBuffer - - -import org.apache.atlas.gremlin.GremlinExpressionFactory -import org.apache.atlas.gremlin.optimizer.GremlinQueryOptimizer -import org.apache.atlas.groovy.CastExpression -import org.apache.atlas.groovy.ClosureExpression -import org.apache.atlas.groovy.LabeledExpression -import org.apache.atlas.groovy.FunctionCallExpression -import org.apache.atlas.groovy.GroovyExpression -import org.apache.atlas.groovy.GroovyGenerationContext -import org.apache.atlas.groovy.IdentifierExpression -import org.apache.atlas.groovy.ListExpression -import org.apache.atlas.groovy.LiteralExpression -import org.apache.atlas.groovy.TraversalStepType -import org.apache.atlas.query.Expressions.AliasExpression -import org.apache.atlas.query.Expressions.ArithmeticExpression -import org.apache.atlas.query.Expressions.BackReference -import org.apache.atlas.query.Expressions.ClassExpression -import org.apache.atlas.query.Expressions.ComparisonExpression -import org.apache.atlas.query.Expressions.Expression -import org.apache.atlas.query.Expressions.ExpressionException -import org.apache.atlas.query.Expressions.FieldExpression -import org.apache.atlas.query.Expressions.FilterExpression -import org.apache.atlas.query.Expressions.InstanceExpression -import org.apache.atlas.query.Expressions.LimitExpression -import org.apache.atlas.query.Expressions.ListLiteral -import org.apache.atlas.query.Expressions.Literal -import org.apache.atlas.query.Expressions.LogicalExpression -import org.apache.atlas.query.Expressions.LoopExpression -import org.apache.atlas.query.Expressions.OrderExpression -import org.apache.atlas.query.Expressions.PathExpression -import org.apache.atlas.query.Expressions.SelectExpression -import org.apache.atlas.query.Expressions.TraitExpression -import org.apache.atlas.query.Expressions.TraitInstanceExpression -import org.apache.atlas.query.Expressions.hasFieldLeafExpression -import org.apache.atlas.query.Expressions.hasFieldUnaryExpression -import org.apache.atlas.query.Expressions.id -import org.apache.atlas.query.Expressions.isTraitLeafExpression -import org.apache.atlas.query.Expressions.isTraitUnaryExpression -import org.apache.atlas.repository.RepositoryException -import org.apache.atlas.repository.graphdb.AtlasEdgeDirection -import org.apache.atlas.typesystem.types.DataTypes -import org.apache.atlas.typesystem.types.DataTypes.TypeCategory -import org.apache.atlas.typesystem.types.IDataType -import org.apache.atlas.typesystem.types.TypeSystem -import org.joda.time.format.ISODateTimeFormat -import org.apache.atlas.query.Expressions.GroupByExpression -import org.apache.atlas.query.Expressions.MaxExpression -import org.apache.atlas.query.Expressions.MinExpression -import org.apache.atlas.query.Expressions.SumExpression -import org.apache.atlas.query.Expressions.CountExpression - -import org.apache.atlas.util.AtlasRepositoryConfiguration -import java.util.HashSet - -trait IntSequence { -def next: Int -} - -case class GremlinQuery(expr: Expression, queryStr: String, resultMaping: Map[String, (String, Int)]) { - -def hasSelectList = resultMaping != null - -def isPathExpression = expr.isInstanceOf[PathExpression] - -def isGroupBy = expr.isInstanceOf[GroupByExpression] -} - - -trait Select
[19/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java -- diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java deleted file mode 100755 index 952a644..000 --- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java +++ /dev/null @@ -1,864 +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.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import org.apache.atlas.AtlasException; -import org.apache.atlas.CreateUpdateEntitiesResult; -import org.apache.atlas.RequestContext; -import org.apache.atlas.TestModules; -import org.apache.atlas.TestUtils; -import org.apache.atlas.annotation.GraphTransaction; -import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService; -import org.apache.atlas.query.QueryParams; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.MetadataRepository; -import org.apache.atlas.repository.RepositoryException; -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.AtlasGraphQuery; -import org.apache.atlas.repository.graphdb.AtlasGraphQuery.ComparisionOperator; -import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.ITypedStruct; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.exception.EntityNotFoundException; -import org.apache.atlas.typesystem.exception.TraitNotFoundException; -import org.apache.atlas.typesystem.persistence.AtlasSystemAttributes; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.AttributeDefinition; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.DataTypes; -import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition; -import org.apache.atlas.typesystem.types.Multiplicity; -import org.apache.atlas.typesystem.types.TraitType; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.apache.atlas.typesystem.types.utils.TypesUtil; -import org.apache.commons.lang.RandomStringUtils; -import org.codehaus.jettison.json.JSONArray; -import org.codehaus.jettison.json.JSONObject; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef; -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createUniqueRequiredAttrDef; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -/** - * GraphBackedMetadataRepository test - * - * Guice loads the dependencies and injects the necessary objects - * - */ -@Guice(modules = TestModules.TestOnlyModule.class) -public class GraphBackedMetadataRepositoryTest { - -@Inject -private MetadataRepository repositoryService; - -@Inject -priv
[28/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/repository/memory/MemRepository.java -- diff --git a/repository/src/main/java/org/apache/atlas/repository/memory/MemRepository.java b/repository/src/main/java/org/apache/atlas/repository/memory/MemRepository.java deleted file mode 100755 index aef06a4..000 --- a/repository/src/main/java/org/apache/atlas/repository/memory/MemRepository.java +++ /dev/null @@ -1,299 +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.memory; - -import org.apache.atlas.AtlasException; -import org.apache.atlas.repository.DiscoverInstances; -import org.apache.atlas.repository.IRepository; -import org.apache.atlas.repository.RepositoryException; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.persistence.MapIds; -import org.apache.atlas.typesystem.persistence.ReferenceableInstance; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.DataTypes; -import org.apache.atlas.typesystem.types.HierarchicalType; -import org.apache.atlas.typesystem.types.HierarchicalTypeDependencySorter; -import org.apache.atlas.typesystem.types.Multiplicity; -import org.apache.atlas.typesystem.types.ObjectGraphWalker; -import org.apache.atlas.typesystem.types.TraitType; -import org.apache.atlas.typesystem.types.TypeSystem; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.atomic.AtomicInteger; - -@Deprecated -public class MemRepository implements IRepository { - -final TypeSystem typeSystem; -/* - * A Store for each Class and Trait. - */ -final Map typeStores; -final AtomicInteger ID_SEQ = new AtomicInteger(0); - -public MemRepository(TypeSystem typeSystem) { -this.typeSystem = typeSystem; -this.typeStores = new HashMap<>(); -} - -@Override -public Id newId(String typeName) { -return new Id("" + ID_SEQ.incrementAndGet(), 0, typeName); -} - -/** - * 1. traverse the Object Graph from i and create idToNewIdMap : Map[Id, Id], - *also create old Id to Instance Map: oldIdToInstance : Map[Id, IInstance] - * - traverse reference Attributes, List[ClassType], Maps where Key/value is ClassType - * - traverse Structs - * - traverse Traits. - * 1b. Ensure that every newId has an associated Instance. - * 2. Traverse oldIdToInstance map create newInstances : List[ITypedReferenceableInstance] - *- create a ITypedReferenceableInstance. - * replace any old References ( ids or object references) with new Ids. - * 3. Traverse over newInstances - *- ask ClassStore to assign a position to the Id. - * - for Instances with Traits, assign a position for each Trait - *- invoke store on the nwInstance. - * - * Recovery: - * - on each newInstance, invoke releaseId and delete on its ClassStore and Traits' Stores. - * - * @param i - * @return - * @throws org.apache.atlas.repository.RepositoryException - */ -public ITypedReferenceableInstance create(IReferenceableInstance i) throws RepositoryException { - -DiscoverInstances discoverInstances = new DiscoverInstances(this); - -/* - * Step 1: traverse the Object Graph from i and create idToNewIdMap : Map[Id, Id], - *also create old Id to Instance Map: oldIdToInstance : Map[Id, IInstance] - * - traverse reference Attributes, List[ClassType], Maps where Key/value is ClassType - * - traverse Structs - * - traverse Traits. - */ -try { -new ObjectGraphWalker(typeSystem, discoverInstances, i).walk(); -} catch (AtlasException me) { -throw new RepositoryException("TypeSystem error when walking the ObjectGraph", me); -
[39/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java -- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java b/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java new file mode 100644 index 000..c70e7d0 --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java @@ -0,0 +1,357 @@ +/** + * 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.v1.model.notification; + +import org.apache.atlas.model.notification.HookNotification; +import org.apache.atlas.model.typedef.AtlasBaseTypeDef; +import org.apache.atlas.v1.model.instance.Referenceable; +import org.apache.atlas.v1.model.typedef.TypesDef; +import org.codehaus.jackson.annotate.JsonAutoDetect; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * Contains the structure of messages transferred from hooks to atlas. + */ +public class HookNotificationV1 { + +/** + * Hook message for create type definitions. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS) +@JsonIgnoreProperties(ignoreUnknown=true) +@XmlRootElement +@XmlAccessorType(XmlAccessType.PROPERTY) +public static class TypeRequest extends HookNotification implements Serializable { +private static final long serialVersionUID = 1L; + +private TypesDef typesDef; + +public TypeRequest() { +} + +public TypeRequest(HookNotificationType type, TypesDef typesDef, String user) { +super(type, user); +this.typesDef = typesDef; +} + +public TypesDef getTypesDef() { +return typesDef; +} + +public void setTypesDef(TypesDef typesDef) { +this.typesDef = typesDef; +} + +@Override +public StringBuilder toString(StringBuilder sb) { +if (sb == null) { +sb = new StringBuilder(); +} + +sb.append("TypeRequest{"); +super.toString(sb); +sb.append("typesDef="); +if (typesDef != null) { +typesDef.toString(sb); +} +sb.append("}"); + +return sb; +} +} + +/** + * Hook message for creating new entities. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS) +@JsonIgnoreProperties(ignoreUnknown=true) +@XmlRootElement +@XmlAccessorType(XmlAccessType.PROPERTY) +public static class EntityCreateRequest extends HookNotification implements Serializable { +private static final long serialVersionUID = 1L; + +private List entities; + +public EntityCreateRequest() { +} + +public EntityCreateRequest(String user, Referenceable... entities) { +this(HookNotificationType.ENTITY_CREATE, Arrays.asList(entities), user); +} + +public EntityCreateRequest(String user, List entities) { +this(HookNotificationType.ENTITY_CREATE, entities, user); +} + +protected EntityCreateRequest(HookNotificationType type, List entities, String user) { +super(type, user); + +this.entities = entities; +} + +public List getEntities() { +return entities; +} + +public void setEntities(List entities) { +this.entities = en
[10/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java -- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java deleted file mode 100755 index f9f4abe..000 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java +++ /dev/null @@ -1,655 +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.typesystem.types; - -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import org.apache.atlas.AtlasException; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.commons.lang3.StringUtils; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormatter; -import org.joda.time.format.ISODateTimeFormat; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.nio.charset.Charset; -import java.security.MessageDigest; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class DataTypes { - -public static BooleanType BOOLEAN_TYPE = new BooleanType(); -public static ByteType BYTE_TYPE = new ByteType(); -public static ShortType SHORT_TYPE = new ShortType(); -public static IntType INT_TYPE = new IntType(); -public static LongType LONG_TYPE = new LongType(); -public static FloatType FLOAT_TYPE = new FloatType(); -public static DoubleType DOUBLE_TYPE = new DoubleType(); -public static BigIntegerType BIGINTEGER_TYPE = new BigIntegerType(); -public static BigDecimalType BIGDECIMAL_TYPE = new BigDecimalType(); -public static DateType DATE_TYPE = new DateType(); -public static StringType STRING_TYPE = new StringType(); -public static String ARRAY_TYPE_PREFIX = "array<"; -static String ARRAY_TYPE_SUFFIX = ">"; -public static String MAP_TYPE_PREFIX = "map<"; -static String MAP_TYPE_SUFFIX = ">"; - -public static String arrayTypeName(String elemTypeName) { -assert elemTypeName != null; -return String.format("%s%s%s", ARRAY_TYPE_PREFIX, elemTypeName, ARRAY_TYPE_SUFFIX); -} - -public static String arrayTypeName(IDataType elemType) { -return arrayTypeName(elemType.getName()); -} - -public static String mapTypeName(String keyTypeName, String valueTypeName) { -return String.format("%s%s,%s%s", MAP_TYPE_PREFIX, keyTypeName, valueTypeName, MAP_TYPE_SUFFIX); -} - -public static String mapTypeName(IDataType keyType, IDataType valueType) { -assert keyType != null; -assert valueType != null; -return mapTypeName(keyType.getName(), valueType.getName()); -} - -public enum TypeCategory { -PRIMITIVE, -ENUM, -ARRAY, -MAP, -STRUCT, -TRAIT, -CLASS, -RELATIONSHIP -} - -public static abstract class PrimitiveType extends AbstractDataType { -public PrimitiveType(String name, String description) { -super(name, description); -} - -@Override -public TypeCategory getTypeCategory() { -return TypeCategory.PRIMITIVE; -} - -public abstract T nullValue(); - -@Override -protected T convertNull(Multiplicity m) throws AtlasException { -if (!m.nullAllowed()) { -throw new ValueConversionException.NullConversionException(m); -} - -return nullValue(); -} - -@Override -public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException { -if ( val != null ) { - digester.update(val.toString().getBytes(Charset.forName("UTF-8"))); -} -} - -} - -public
[35/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java -- diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java index 7f24d5a..03a86f4 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java +++ b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java @@ -24,7 +24,6 @@ import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasException; import org.apache.atlas.SortOrder; import org.apache.atlas.annotation.GraphTransaction; -import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.discovery.AtlasSearchResult; import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult; @@ -44,7 +43,6 @@ import org.apache.atlas.query.QueryParser; import org.apache.atlas.query.QueryProcessor; import org.apache.atlas.query.SelectExpressionHelper; import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.MetadataRepository; import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.AtlasGraph; @@ -70,9 +68,6 @@ import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import scala.Option; -import scala.util.Either; -import scala.util.parsing.combinator.Parsers.NoSuccess; import javax.inject.Inject; import javax.script.Bindings; @@ -104,7 +99,6 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { private static final String DEFAULT_SORT_ATTRIBUTE_NAME = "name"; private final AtlasGraph graph; -private final DefaultGraphPersistenceStrategy graphPersistenceStrategy; private final EntityGraphRetrieverentityRetriever; private final AtlasGremlinQueryProvider gremlinQueryProvider; private final AtlasTypeRegistry typeRegistry; @@ -116,11 +110,10 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { private final UserProfileService userProfileService; @Inject -EntityDiscoveryService(MetadataRepository metadataRepository, AtlasTypeRegistry typeRegistry, +EntityDiscoveryService(AtlasTypeRegistry typeRegistry, AtlasGraph graph, GraphBackedSearchIndexer indexer, SearchTracker searchTracker, UserProfileService userProfileService) throws AtlasException { this.graph= graph; -this.graphPersistenceStrategy = new DefaultGraphPersistenceStrategy(metadataRepository); this.entityRetriever = new EntityGraphRetriever(typeRegistry); this.indexer = indexer; this.searchTracker= searchTracker; @@ -685,15 +678,14 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { private GremlinQuery toGremlinQuery(String query, int limit, int offset) throws AtlasBaseException { QueryParams params = validateSearchParams(limit, offset); -Either either = QueryParser.apply(query, params); +Expression expression = QueryParser.apply(query, params); -if (either.isLeft()) { +if (expression == null) { throw new AtlasBaseException(DISCOVERY_QUERY_FAILED, query); } -Expression expression = either.right().get(); Expression validExpression = QueryProcessor.validate(expression); -GremlinQuery gremlinQuery= new GremlinTranslator(validExpression, graphPersistenceStrategy).translate(); +GremlinQuery gremlinQuery= new GremlinTranslator(validExpression).translate(); if (LOG.isDebugEnabled()) { LOG.debug("Translated Gremlin Query: {}", gremlinQuery.queryStr()); @@ -730,9 +722,9 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { List> values = new ArrayList<>(); // extract select attributes from gremlin query -Option selectExpr = SelectExpressionHelper.extractSelectExpression(query.expr()); -if (selectExpr.isDefined()) { -List aliases = selectExpr.get().toJavaList(); +SelectExpression selectExpr = SelectExpressionHelper.extractSelectExpression(query.expr()); +if (selectExpr != null) { +List aliases = selectExpr.toJavaList(); if (CollectionUtils.isNotEmpty(aliases)) { for (AliasExpression alias : aliases) { http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/
[18/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java -- diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java deleted file mode 100755 index 1f077ba..000 --- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java +++ /dev/null @@ -1,241 +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 org.apache.atlas.ApplicationProperties; -import org.apache.atlas.CreateUpdateEntitiesResult; -import org.apache.atlas.TestModules; -import org.apache.atlas.TestUtils; -import org.apache.atlas.annotation.GraphTransaction; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.RepositoryException; -import org.apache.atlas.repository.graphdb.AtlasGraph; -import org.apache.atlas.repository.graphdb.AtlasGraphQuery; -import org.apache.atlas.repository.graphdb.AtlasGraphQuery.ComparisionOperator; -import org.apache.atlas.repository.graphdb.AtlasIndexQuery; -import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.exception.EntityExistsException; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.IDataType; -import org.apache.atlas.typesystem.types.Multiplicity; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; - -@Test -@Guice(modules = TestModules.TestOnlyModule.class) -public class GraphRepoMapperScaleTest { - -private static final String DATABASE_NAME = "foo"; -private static final String TABLE_NAME = "bar"; - -@Inject -private GraphBackedMetadataRepository repositoryService; - -@Inject -private GraphBackedSearchIndexer searchIndexer; - -private TypeSystem typeSystem = TypeSystem.getInstance(); - -private String dbGUID; - -@BeforeClass -@GraphTransaction -public void setUp() throws Exception { -//force up front graph initialization -TestUtils.getGraph(); -searchIndexer = new GraphBackedSearchIndexer(new AtlasGraphProvider(), ApplicationProperties.get(), new AtlasTypeRegistry()); -//Make sure we can cleanup the index directory -Collection typesAdded = TestUtils.createHiveTypes(typeSystem); -searchIndexer.onAdd(typesAdded); -} - -@BeforeMethod -public void setupContext() { -TestUtils.resetRequestContext(); -} - -@AfterClass -public void tearDown() throws Exception { -TypeSystem.getInstance().reset(); -//AtlasGraphProvider.cleanup(); -} - -@Test -public void testSubmitEntity() throws Exception { -Referenceable databaseInstance = new Referenceable(TestUtils.DATABASE_TYPE); -databaseInstance.set("name", DATABASE_NAME); -databaseInstance.set("description", "foo database"); -// System.out.println("databaseInstance = " + databaseInstance); - -ClassType dbType = typeSystem.getDataType(ClassType.class, TestUtils.DATABASE_TYPE); -ITypedReferenceableInstance db = dbType.convert(databaseInstance, Multiplicity.REQUIRED); - -dbGUID = result(db).getCreatedEntities().get(0); - -Referenceable dbInstance = new Referenceable(dbGUID, TestUtils.DATABASE_TYPE, databaseInstance.getValuesMap()); - -for (int index = 0; index < 1000; ind
[27/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java -- diff --git a/repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java b/repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java deleted file mode 100755 index 9eb695c..000 --- a/repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java +++ /dev/null @@ -1,821 +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.services; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import org.apache.atlas.AtlasClient; -import org.apache.atlas.AtlasErrorCode; -import org.apache.atlas.AtlasException; -import org.apache.atlas.CreateUpdateEntitiesResult; -import org.apache.atlas.EntityAuditEvent; -import org.apache.atlas.RequestContext; -import org.apache.atlas.exception.AtlasBaseException; -import org.apache.atlas.ha.HAConfiguration; -import org.apache.atlas.listener.ActiveStateChangeHandler; -import org.apache.atlas.listener.ChangedTypeDefs; -import org.apache.atlas.listener.EntityChangeListener; -import org.apache.atlas.listener.TypeDefChangeListener; -import org.apache.atlas.listener.TypesChangeListener; -import org.apache.atlas.model.legacy.EntityResult; -import org.apache.atlas.repository.MetadataRepository; -import org.apache.atlas.repository.RepositoryException; -import org.apache.atlas.repository.audit.EntityAuditRepository; -import org.apache.atlas.repository.graph.GraphHelper; -import org.apache.atlas.repository.typestore.ITypeStore; -import org.apache.atlas.type.AtlasTypeUtil; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.ITypedStruct; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.TypesDef; -import org.apache.atlas.typesystem.exception.EntityNotFoundException; -import org.apache.atlas.typesystem.exception.TypeNotFoundException; -import org.apache.atlas.typesystem.json.InstanceSerialization; -import org.apache.atlas.typesystem.json.TypesSerialization; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.persistence.ReferenceableInstance; -import org.apache.atlas.typesystem.types.*; -import org.apache.atlas.typesystem.types.cache.TypeCache; -import org.apache.atlas.utils.ParamChecker; -import org.apache.commons.configuration.Configuration; -import org.codehaus.jettison.json.JSONException; -import org.codehaus.jettison.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - - - -/** - * Simple wrapper over TypeSystem and MetadataRepository services with hooks - * for listening to changes to the repository. - */ -@Singleton -@Component -@Deprecated -public class DefaultMetadataService implements MetadataService, ActiveStateChangeHandler, TypeDefChangeListener { -private enum OperationType { -CREATE, UPDATE, DELETE -}; - -private static final Logger LOG = LoggerFactory.getLogger(DefaultMetadataService.class); -private final short maxAuditResults; -private static final String CONFIG_MAX_AUDIT_RESULTS = "atlas.audit.maxResults"; -private static final short DEFAULT_MAX_AUDIT_RESULTS = 1000; - -private final TypeSystem typeSystem; -private final MetadataRepository repository; -private final ITypeStore typeStore; - -private final Collection typeChangeListeners = new LinkedHashSet<>(); -private final Collection entityChangeListeners = new LinkedHashSet<>(); - -private EntityAuditRepository auditRepository; - -@Inject -public DefaultMetadataS
[02/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java -- diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java index e753881..98df12b 100644 --- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java +++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java @@ -18,7 +18,6 @@ package org.apache.atlas.web.adapters; import org.apache.atlas.AtlasClient; -import org.apache.atlas.RequestContext; import org.apache.atlas.RequestContextV1; import org.apache.atlas.TestModules; import org.apache.atlas.TestUtilsV2; @@ -99,7 +98,6 @@ public class TestEntitiesREST { @AfterMethod public void cleanup() throws Exception { -RequestContext.clear(); RequestContextV1.clear(); } http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java -- diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java index b90ea64..ea6fe31 100644 --- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java +++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java @@ -18,7 +18,6 @@ package org.apache.atlas.web.adapters; import org.apache.atlas.TestModules; -import org.apache.atlas.RequestContext; import org.apache.atlas.RequestContextV1; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.model.instance.AtlasClassification; @@ -77,7 +76,6 @@ public class TestEntityREST { @AfterMethod public void cleanup() throws Exception { -RequestContext.clear(); RequestContextV1.clear(); } http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java -- diff --git a/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java b/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java index 5628b17..a3f5601 100644 --- a/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java +++ b/webapp/src/test/java/org/apache/atlas/web/filters/AtlasAuthenticationKerberosFilterTest.java @@ -16,7 +16,7 @@ */ package org.apache.atlas.web.filters; -import org.apache.atlas.RequestContext; +import org.apache.atlas.RequestContextV1; import org.apache.atlas.web.security.BaseSecurityTest; import org.apache.atlas.web.service.EmbeddedServer; import org.apache.commons.configuration.PropertiesConfiguration; @@ -111,7 +111,7 @@ public class AtlasAuthenticationKerberosFilterTest extends BaseSecurityTest { connection.connect(); assertEquals(connection.getResponseCode(), 200); -assertEquals(RequestContext.get().getUser(), TESTUSER); +assertEquals(RequestContextV1.get().getUser(), TESTUSER); return null; } }); http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java -- diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java index 512750f..ab27612 100755 --- a/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java @@ -19,8 +19,6 @@ package org.apache.atlas.web.integration; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClientV2; @@ -32,26 +30,21 @@ import org.apache.atlas.model.instance.AtlasEntityHeader; import org.apache.atlas.model.instance.AtlasStruct; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.instance.EntityMutations; -import org.apache.atlas.model.typedef.AtlasClassificationDef; -import org.apache.atlas.model.typedef.AtlasEntityDef; -import org.apache.atlas.model.typedef.AtlasEnumDef; -import org.apache.atlas.model.typedef.AtlasStructDef; +import org.apache.atlas.model.typedef.*; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDe
[23/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/discovery/DataSetLineageServiceTest.java -- diff --git a/repository/src/test/java/org/apache/atlas/discovery/DataSetLineageServiceTest.java b/repository/src/test/java/org/apache/atlas/discovery/DataSetLineageServiceTest.java deleted file mode 100644 index 3db58fe..000 --- a/repository/src/test/java/org/apache/atlas/discovery/DataSetLineageServiceTest.java +++ /dev/null @@ -1,497 +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.discovery; - -import com.google.common.collect.ImmutableList; -import org.apache.atlas.AtlasException; -import org.apache.atlas.BaseRepositoryTest; -import org.apache.atlas.TestModules; -import org.apache.atlas.TestUtils; -import org.apache.atlas.model.legacy.EntityResult; -import org.apache.atlas.query.QueryParams; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.exception.EntityNotFoundException; -import org.apache.atlas.typesystem.json.InstanceSerialization; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.commons.collections.ArrayStack; -import org.codehaus.jettison.json.JSONArray; -import org.codehaus.jettison.json.JSONException; -import org.codehaus.jettison.json.JSONObject; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import javax.inject.Inject; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -/** - * Unit tests for Hive LineageService. - */ -@Guice(modules = TestModules.TestOnlyModule.class) -public class DataSetLineageServiceTest extends BaseRepositoryTest { - -@Inject -private DiscoveryService discoveryService; - -@Inject -private DataSetLineageService lineageService; - -@BeforeClass -public void setUp() throws Exception { -super.setUp(); -} - -@AfterClass -public void tearDown() throws Exception { -super.tearDown(); -} - -@DataProvider(name = "dslQueriesProvider") -private Object[][] createDSLQueries() { -return new String[][]{ -// joins -{"hive_table where name=\"sales_fact\", columns"}, -{"hive_table where name=\"sales_fact\", columns select name, dataType, comment"}, -{"hive_table where name=\"sales_fact\", columns as c select c.name, c.dataType, c.comment"}, -//{"hive_db as db where (db.name=\"Reporting\"), hive_table as table select db.name, -// table.name"}, -{"from hive_db"}, {"hive_db"}, {"hive_db where hive_db.name=\"Reporting\""}, -{"hive_db hive_db.name = \"Reporting\""}, -{"hive_db where hive_db.name=\"Reporting\" select name, owner"}, {"hive_db has name"}, -//{"hive_db, hive_table"}, -//{"hive_db, hive_process has name"}, -//{"hive_db as db1, hive_table where db1.name = \"Reporting\""}, -//{"hive_db where hive_db.name=\"Reporting\" and hive_db.createTime < " + System -// .currentTimeMillis()}, -{"from hive_table"}, {"hive_table"}, {"hive_table is Dimension"}, -{"hive_column where hive_column isa PII"}, -//{"hive_column where hive_column isa PII select hive_column.name"}, -{"hive_column select hive_column.name"}, {"hive_column select name"}, -{"hive_column where hive_column.name=\"customer_id\""}, {"from hive_table select hive_table.name"}, -{"hive_db where (name = \"Reporting\")"}, -{"hive_db where (name = \"Reporting\") select name as _co
[22/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java -- diff --git a/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java b/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java deleted file mode 100755 index bd730e4..000 --- a/repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java +++ /dev/null @@ -1,1334 +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.discovery; - -import com.google.common.collect.ImmutableSet; -import org.apache.atlas.AtlasException; -import org.apache.atlas.BaseRepositoryTest; -import org.apache.atlas.RequestContext; -import org.apache.atlas.TestModules; -import org.apache.atlas.TestUtils; -import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService; -import org.apache.atlas.query.QueryParams; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.MetadataRepository; -import org.apache.atlas.repository.graph.AtlasGraphProvider; -import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; -import org.apache.atlas.repository.graphdb.GremlinVersion; -import org.apache.atlas.util.AtlasGremlinQueryProvider; -import org.apache.atlas.util.AtlasGremlinQueryProvider.AtlasGremlinQuery; -import org.apache.atlas.type.AtlasTypeRegistry; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.DataTypes; -import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition; -import org.apache.atlas.typesystem.types.IDataType; -import org.apache.atlas.typesystem.types.Multiplicity; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.codehaus.jettison.json.JSONArray; -import org.codehaus.jettison.json.JSONException; -import org.codehaus.jettison.json.JSONObject; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import javax.inject.Inject; -import java.text.SimpleDateFormat; -import java.util.*; - -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef; -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef; -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -@Guice(modules = TestModules.TestOnlyModule.class) -public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { - -@Inject -private MetadataRepository repositoryService; - -@Inject -private GraphBackedDiscoveryService discoveryService; -private QueryParams queryParams = new QueryParams(40, 0); -private static final String idType = "idType"; -@Override -@BeforeClass -public void setUp() throws Exception { -super.setUp(); - -repositoryService = TestUtils.addTransactionWrapper(repositoryService); -final TypeSystem typeSystem = TypeSystem.getInstance(); -Collection oldTypeNames = new HashSet<>(); -oldTypeNames.addAll(typeSystem.getTypeNames()); - -TestUtils.defineDeptEmployeeTypes(typeSystem); - -addIndexesForNewTypes(oldTypeNames, typeSystem); - -ITypedReferenceableInstance hrDept = TestUtils.createDeptEg1(typeSystem); -repositoryService.createEntities(hrDept); - -ITypedReferenceableInstance jane = repositoryService.getEntityDefinition("Manager", "name", "Jane"); -Id janeGuid = jane.getId(); -ClassType personType = typeSystem.getDataType(ClassType.class, "Person"); -ITypedReferenceableInstance instance = personType.createInstance(janeGuid); -i
[04/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java -- diff --git a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java index 53acf56..4633de9 100644 --- a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java +++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java @@ -21,44 +21,34 @@ import com.google.common.annotations.VisibleForTesting; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasException; import org.apache.atlas.listener.EntityChangeListener; -import org.apache.atlas.notification.entity.EntityNotification; -import org.apache.atlas.notification.entity.EntityNotificationImpl; +import org.apache.atlas.notification.NotificationInterface.NotificationType; +import org.apache.atlas.v1.model.instance.Referenceable; +import org.apache.atlas.v1.model.instance.Struct; +import org.apache.atlas.v1.model.notification.EntityNotificationV1; +import org.apache.atlas.v1.model.notification.EntityNotificationV1.OperationType; import org.apache.atlas.repository.graph.GraphHelper; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.types.FieldMapping; -import org.apache.atlas.typesystem.types.TraitType; -import org.apache.atlas.typesystem.types.TypeSystem; +import org.apache.atlas.type.AtlasClassificationType; +import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.configuration.Configuration; import org.springframework.stereotype.Component; import javax.inject.Inject; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * Listen to the repository for entity changes and produce entity change notifications. */ @Component public class NotificationEntityChangeListener implements EntityChangeListener { +private static final String ATLAS_ENTITY_NOTIFICATION_PROPERTY = "atlas.notification.entity"; -private final NotificationInterface notificationInterface; -private final TypeSystem typeSystem; +private final NotificationInterface notificationInterface; +private final AtlasTypeRegistry typeRegistry; +private final Map> notificationAttributesCache = new HashMap<>(); -private Map> notificationAttributesCache = new HashMap<>(); -private static final String ATLAS_ENTITY_NOTIFICATION_PROPERTY = "atlas.notification.entity"; -static Configuration APPLICATION_PROPERTIES = null; +private static Configuration APPLICATION_PROPERTIES = null; @@ -68,45 +58,45 @@ public class NotificationEntityChangeListener implements EntityChangeListener { * Construct a NotificationEntityChangeListener. * * @param notificationInterface the notification framework interface - * @param typeSystem the Atlas type system + * @param typeRegistry the Atlas type system */ @Inject -public NotificationEntityChangeListener(NotificationInterface notificationInterface, TypeSystem typeSystem) { +public NotificationEntityChangeListener(NotificationInterface notificationInterface, AtlasTypeRegistry typeRegistry) { this.notificationInterface = notificationInterface; -this.typeSystem = typeSystem; +this.typeRegistry = typeRegistry; } // - EntityChangeListener -- @Override -public void onEntitiesAdded(Collection entities, boolean isImport) throws AtlasException { -notifyOfEntityEvent(entities, EntityNotification.OperationType.ENTITY_CREATE); +public void onEntitiesAdded(Collection entities, boolean isImport) throws AtlasException { +notifyOfEntityEvent(entities, OperationType.ENTITY_CREATE); } @Override -public void onEntitiesUpdated(Collection entities, boolean isImport) throws AtlasException { -notifyOfEntityEvent(entities, EntityNotification.OperationType.ENTITY_UPDATE); +public void onEntitiesUpdated(Collection entities, boolean isImport) throws AtlasException { +notifyOfEntityEvent(entities, OperationType.ENTITY_UPDATE); } @Override -public void onTraitsAdded(ITypedReferenceableInstance entity, Collection traits) th
[37/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/notification/src/main/java/org/apache/atlas/notification/AtlasNotificationBaseMessage.java -- diff --git a/notification/src/main/java/org/apache/atlas/notification/AtlasNotificationBaseMessage.java b/notification/src/main/java/org/apache/atlas/notification/AtlasNotificationBaseMessage.java deleted file mode 100644 index 3b377de..000 --- a/notification/src/main/java/org/apache/atlas/notification/AtlasNotificationBaseMessage.java +++ /dev/null @@ -1,194 +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.notification; - - -import org.apache.atlas.AtlasConfiguration; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.codec.binary.StringUtils; -import org.apache.commons.compress.utils.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - - -public class AtlasNotificationBaseMessage { -private static final Logger LOG = LoggerFactory.getLogger(AtlasNotificationBaseMessage.class); - -public static final int MESSAGE_MAX_LENGTH_BYTES= AtlasConfiguration.NOTIFICATION_MESSAGE_MAX_LENGTH_BYTES.getInt() - 512; // 512 bytes for envelop; -public static final boolean MESSAGE_COMPRESSION_ENABLED = AtlasConfiguration.NOTIFICATION_MESSAGE_COMPRESSION_ENABLED.getBoolean(); - -public enum CompressionKind { NONE, GZIP }; - -private MessageVersion version= null; -private String msgId = null; -private CompressionKind msgCompressionKind = CompressionKind.NONE; -private int msgSplitIdx= 1; -private int msgSplitCount = 1; - - -public AtlasNotificationBaseMessage() { -} - -public AtlasNotificationBaseMessage(MessageVersion version) { -this(version, null, CompressionKind.NONE); -} - -public AtlasNotificationBaseMessage(MessageVersion version, String msgId, CompressionKind msgCompressionKind) { -this.version= version; -this.msgId = msgId; -this.msgCompressionKind = msgCompressionKind; -} - -public AtlasNotificationBaseMessage(MessageVersion version, String msgId, CompressionKind msgCompressionKind, int msgSplitIdx, int msgSplitCount) { -this.version= version; -this.msgId = msgId; -this.msgCompressionKind = msgCompressionKind; -this.msgSplitIdx= msgSplitIdx; -this.msgSplitCount = msgSplitCount; -} - -public void setVersion(MessageVersion version) { -this.version = version; -} - -public MessageVersion getVersion() { -return version; -} - -public String getMsgId() { -return msgId; -} - -public void setMsgId(String msgId) { -this.msgId = msgId; -} - -public CompressionKind getMsgCompressionKind() { -return msgCompressionKind; -} - -public void setMsgCompressed(CompressionKind msgCompressionKind) { -this.msgCompressionKind = msgCompressionKind; -} - -public int getMsgSplitIdx() { -return msgSplitIdx; -} - -public void setMsgSplitIdx(int msgSplitIdx) { -this.msgSplitIdx = msgSplitIdx; -} - -public int getMsgSplitCount() { -return msgSplitCount; -} - -public void setMsgSplitCount(int msgSplitCount) { -this.msgSplitCount = msgSplitCount; -} - -/** - * Compare the version of this message with the given version. - * - * @param compareToVersion the version to compare to - * - * @return a negative integer, zero, or a positive integer as this message's version is less than, equal to, - * or greater than the given version. - */ -public int compareVersion(MessageVersion compareToVersion) { -return version.compareTo(compareToVersion); -} - - -public static byte[] getBytesUtf8(String str) { -retu
[29/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java -- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java deleted file mode 100644 index 1fb4ee9..000 --- a/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java +++ /dev/null @@ -1,941 +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.google.common.base.Function; -import com.google.common.collect.Lists; -import org.apache.atlas.AtlasException; -import org.apache.atlas.RequestContext; -import org.apache.atlas.model.instance.GuidMapping; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.RepositoryException; -import org.apache.atlas.repository.graphdb.AtlasEdge; -import org.apache.atlas.repository.graphdb.AtlasSchemaViolationException; -import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.ITypedInstance; -import org.apache.atlas.typesystem.ITypedReferenceableInstance; -import org.apache.atlas.typesystem.ITypedStruct; -import org.apache.atlas.typesystem.exception.EntityExistsException; -import org.apache.atlas.typesystem.exception.EntityNotFoundException; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.persistence.ReferenceableInstance; -import org.apache.atlas.typesystem.types.*; -import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; -import org.apache.atlas.typesystem.types.utils.TypesUtil; -import org.apache.atlas.util.AtlasRepositoryConfiguration; -import org.apache.atlas.utils.SHA256Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import javax.inject.Inject; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.apache.atlas.repository.graph.GraphHelper.string; - -@Component -@Deprecated -public final class TypedInstanceToGraphMapper { - -private static final Logger LOG = LoggerFactory.getLogger(TypedInstanceToGraphMapper.class); -private final Map idToVertexMap = new HashMap<>(); -private final TypeSystem typeSystem = TypeSystem.getInstance(); -private static final GraphHelper graphHelper = GraphHelper.getInstance(); - -private DeleteHandler deleteHandler; -private GraphToTypedInstanceMapper graphToTypedInstanceMapper; - -@Inject -public TypedInstanceToGraphMapper(GraphToTypedInstanceMapper graphToTypedInstanceMapper, DeleteHandler deleteHandler) { -this.graphToTypedInstanceMapper = graphToTypedInstanceMapper; -this.deleteHandler = deleteHandler; -} - -private final String SIGNATURE_HASH_PROPERTY_KEY = Constants.INTERNAL_PROPERTY_KEY_PREFIX + "signature"; - -public enum Operation { -CREATE, -UPDATE_PARTIAL, -UPDATE_FULL -} - -void mapTypedInstanceToGraph(Operation operation, ITypedReferenceableInstance... typedInstances) -throws AtlasException { - -RequestContext requestContext = RequestContext.get(); -Collection allNewInstances = new ArrayList<>(); -for (ITypedReferenceableInstance typedInstance : typedInstances) { -allNewInstances.addAll(walkClassInstances(typedInstance)); -} - -TypeUtils.Pair, List> instancesPair = -createVerticesAndDiscoverInstances(allNewInstances); - -List entitiesToCreate = instancesPair.left; -List entitiesToUpdate = instancesPair.right; - -FullTextMapper fulltextMapper = new FullTextMapper(this, graphToTypedInstanceMapper); -switch (operation) { -case CREAT
[38/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/intg/src/test/java/org/apache/atlas/TestUtilsV2.java -- diff --git a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java index 91fdb47..bbccf77 100755 --- a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java +++ b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java @@ -18,8 +18,6 @@ package org.apache.atlas; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; @@ -30,7 +28,6 @@ import org.apache.atlas.model.typedef.AtlasClassificationDef; import org.apache.atlas.model.typedef.AtlasEntityDef; import org.apache.atlas.model.typedef.AtlasEnumDef; import org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef; -import org.apache.atlas.model.typedef.AtlasRelationshipDef; import org.apache.atlas.model.typedef.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality; @@ -92,7 +89,7 @@ public final class TestUtilsV2 { AtlasTypeUtil.createRequiredAttrDef("city", "string")); AtlasEntityDef deptTypeDef = -AtlasTypeUtil.createClassTypeDef(DEPARTMENT_TYPE, "Department"+_description, ImmutableSet.of(), +AtlasTypeUtil.createClassTypeDef(DEPARTMENT_TYPE, "Department"+_description, Collections.emptySet(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"), new AtlasAttributeDef("employees", String.format("array<%s>", "Employee"), true, AtlasAttributeDef.Cardinality.SINGLE, 0, 1, false, false, @@ -100,7 +97,7 @@ public final class TestUtilsV2 { add(new AtlasStructDef.AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)); }})); -AtlasEntityDef personTypeDef = AtlasTypeUtil.createClassTypeDef("Person", "Person"+_description, ImmutableSet.of(), +AtlasEntityDef personTypeDef = AtlasTypeUtil.createClassTypeDef("Person", "Person"+_description, Collections.emptySet(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"), AtlasTypeUtil.createOptionalAttrDef("address", "Address"), AtlasTypeUtil.createOptionalAttrDef("birthday", "date"), @@ -113,7 +110,7 @@ public final class TestUtilsV2 { AtlasTypeUtil.createOptionalAttrDef("approximationOfPi", "bigdecimal") ); -AtlasEntityDef employeeTypeDef = AtlasTypeUtil.createClassTypeDef("Employee", "Employee"+_description, ImmutableSet.of("Person"), +AtlasEntityDef employeeTypeDef = AtlasTypeUtil.createClassTypeDef("Employee", "Employee"+_description, Collections.singleton("Person"), AtlasTypeUtil.createOptionalAttrDef("orgLevel", "OrgLevel"), new AtlasAttributeDef("department", "Department", false, AtlasAttributeDef.Cardinality.SINGLE, 1, 1, @@ -142,18 +139,18 @@ public final class TestUtilsV2 { put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, "employees"); }})); -AtlasEntityDef managerTypeDef = AtlasTypeUtil.createClassTypeDef("Manager", "Manager"+_description, ImmutableSet.of("Employee"), +AtlasEntityDef managerTypeDef = AtlasTypeUtil.createClassTypeDef("Manager", "Manager"+_description, Collections.singleton("Employee"), new AtlasAttributeDef("subordinates", String.format("array<%s>", "Employee"), false, AtlasAttributeDef.Cardinality.SET, 1, 10, false, false, Collections.emptyList())); AtlasClassificationDef securityClearanceTypeDef = -AtlasTypeUtil.createTraitTypeDef("SecurityClearance", "SecurityClearance"+_description, ImmutableSet.of(), +AtlasTypeUtil.createTraitTypeDef("SecurityClearance", "SecurityClearance"+_description, Collections.emptySet(), AtlasTypeUtil.createRequiredAttrDef("level", "int")); -AtlasTypesDef ret = new AtlasTypesDef(ImmutableList.of(orgLevelEnum), ImmutableList.of(addressDetails), -ImmutableList.of(securityClearanceTypeDef), -ImmutableList.of(deptTypeDef, personTypeDef, employeeTypeDef, managerTypeDef)); +AtlasTypesDef ret = new AtlasTypesDef(Collections.singletonList(orgLevelEnum), Collections.singletonList(addressDetails), +Collections.singletonList(securityClearanceTypeDef), +Arrays.asList(deptTypeDef, pe
[31/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java -- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java b/repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java deleted file mode 100644 index f0fef1f..000 --- a/repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java +++ /dev/null @@ -1,468 +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 static org.apache.atlas.repository.graph.GraphHelper.EDGE_LABEL_PREFIX; -import static org.apache.atlas.repository.graph.GraphHelper.string; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.atlas.AtlasException; -import org.apache.atlas.RequestContext; -import org.apache.atlas.repository.Constants; -import org.apache.atlas.repository.graph.GraphHelper.VertexInfo; -import org.apache.atlas.repository.graphdb.AtlasEdge; -import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; -import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.typesystem.exception.NullRequiredAttributeException; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.AttributeInfo; -import org.apache.atlas.typesystem.types.DataTypes; -import org.apache.atlas.typesystem.types.FieldMapping; -import org.apache.atlas.typesystem.types.HierarchicalType; -import org.apache.atlas.typesystem.types.IDataType; -import org.apache.atlas.typesystem.types.StructType; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public abstract class DeleteHandler { -public static final Logger LOG = LoggerFactory.getLogger(DeleteHandler.class); - -protected static final GraphHelper graphHelper = GraphHelper.getInstance(); - -protected TypeSystem typeSystem; -private boolean shouldUpdateReverseAttribute; -private boolean softDelete; - -public DeleteHandler(TypeSystem typeSystem, boolean shouldUpdateReverseAttribute, boolean softDelete) { -this.typeSystem = typeSystem; -this.shouldUpdateReverseAttribute = shouldUpdateReverseAttribute; -this.softDelete = softDelete; -} - -/** - * Deletes the specified entity vertices. - * Deletes any traits, composite entities, and structs owned by each entity. - * Also deletes all the references from/to the entity. - * - * @param instanceVertices - * @throws AtlasException - */ -public void deleteEntities(Collection instanceVertices) throws AtlasException { - RequestContext requestContext = RequestContext.get(); - - Set deletionCandidateVertices = new HashSet<>(); - - for (AtlasVertex instanceVertex : instanceVertices) { -String guid = GraphHelper.getGuid(instanceVertex); -Id.EntityState state = GraphHelper.getState(instanceVertex); -if (requestContext.getDeletedEntityIds().contains(guid) || state == Id.EntityState.DELETED) { -if (LOG.isDebugEnabled()) { -LOG.debug("Skipping deletion of {} as it is already deleted", guid); -} - -continue; -} - - // Get GUIDs and vertices for all deletion candidates. - Set compositeVertices = graphHelper.getCompositeVertices(instanceVertex); - - // Record all deletion candidate GUIDs in RequestContext - // and gather deletion candidate vertices. - for (VertexInfo vertexInfo : compositeVertices) { - requestContext.recordEntityDelete(vertexInfo.getGuid(), vertexInfo.getTypeName()); - deletionCandidateVertices.add(vertexInfo.getVertex()); - } - } - - // Delete traits and vertices. - for (AtlasVertex deletionCandidateVertex : deletionCandidateVertices) { - deleteAllTraits(d
[12/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/server-api/src/main/java/org/apache/atlas/typesystem/exception/TraitNotFoundException.java -- diff --git a/server-api/src/main/java/org/apache/atlas/typesystem/exception/TraitNotFoundException.java b/server-api/src/main/java/org/apache/atlas/typesystem/exception/TraitNotFoundException.java deleted file mode 100644 index 2d5663e..000 --- a/server-api/src/main/java/org/apache/atlas/typesystem/exception/TraitNotFoundException.java +++ /dev/null @@ -1,45 +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.typesystem.exception; - -/** - * A simple wrapper for 404. - * Thrown when a requested trait can not be found. - */ -public class TraitNotFoundException extends NotFoundException { -public TraitNotFoundException() { -} - -public TraitNotFoundException(String message) { -super(message); -} - -public TraitNotFoundException(String message, Throwable cause) { -super(message, cause); -} - -public TraitNotFoundException(Throwable cause) { -super(cause); -} - -public TraitNotFoundException(String message, Throwable cause, boolean enableSuppression, -boolean writableStackTrace) { -super(message, cause, enableSuppression, writableStackTrace); -} -} http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/.gitignore -- diff --git a/typesystem/.gitignore b/typesystem/.gitignore deleted file mode 100755 index c7029f8..000 --- a/typesystem/.gitignore +++ /dev/null @@ -1,35 +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. - -# Eclipse -.classpath -.project -.settings/ - -# Intellij -.idea/ -*.iml -*.iws - -# Mac -.DS_Store - -# Maven -log/ -target/ - -# Emacs -*~ http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/LICENSE.md -- diff --git a/typesystem/LICENSE.md b/typesystem/LICENSE.md deleted file mode 100755 index 5c304d1..000 --- a/typesystem/LICENSE.md +++ /dev/null @@ -1,201 +0,0 @@ -Apache License - Version 2.0, January 2004 -http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but
[05/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/src/test/scala/org/apache/atlas/typesystem/builders/MultiplicityTest.scala -- diff --git a/typesystem/src/test/scala/org/apache/atlas/typesystem/builders/MultiplicityTest.scala b/typesystem/src/test/scala/org/apache/atlas/typesystem/builders/MultiplicityTest.scala deleted file mode 100644 index 91e72c7..000 --- a/typesystem/src/test/scala/org/apache/atlas/typesystem/builders/MultiplicityTest.scala +++ /dev/null @@ -1,124 +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.typesystem.builders - -import org.apache.atlas.AtlasException -import org.apache.atlas.typesystem.types.{ClassType, Multiplicity, TypeSystem} -import org.testng.annotations.{BeforeMethod,Test} - -class MultiplicityTest { - - @BeforeMethod - def beforeAll { -TypeSystem.getInstance().reset() - -val b = new TypesBuilder -import b._ - -val tDef = types { - - _trait("Dimension") {} - _trait("PII") {} - _trait("Metric") {} - _trait("ETL") {} - _trait("JdbcAccess") {} - - _class("DB") { -"name" ~ (string, required, indexed, unique) -"owner" ~ (string) -"createTime" ~ (int) - } - - _class("StorageDesc") { -"inputFormat" ~ (string, required) -"outputFormat" ~ (string, required) - } - - _class("Column") { -"name" ~ (string, required) -"dataType" ~ (string, required) -"sd" ~ ("StorageDesc", required) - } - - _class("Table", List()) { -"name" ~ (string, required, indexed) -"db" ~ ("DB", required) -"sd" ~ ("StorageDesc", required) - } - - _class("LoadProcess") { -"name" ~ (string, required) -"inputTables" ~ (array("Table"), collection) -"outputTable" ~ ("Table", required) - - } - - _class("View") { -"name" ~ (string, required) -"inputTables" ~ (array("Table"), collection) - } - - _class("AT") { -"name" ~ (string, required) -"stringSet" ~ (array("string"), multiplicty(0, Int.MaxValue, true)) - } -} - -TypeSystem.getInstance().defineTypes(tDef) - } - - @Test - def test1 { - -val b = new InstanceBuilder -import b._ - -val instances = b create { - val a = instance("AT") { // use instance to create Referenceables. use closure to -// set attributes of instance -'name ~ "A1" // use '~' to set attributes. Use a Symbol (names starting with ') for -'stringSet ~ Seq("a", "a") - } -} - -val ts = TypeSystem.getInstance() -import scala.collection.JavaConversions._ -val typedInstances = instances.map { i => - val iTyp = ts.getDataType(classOf[ClassType], i.getTypeName) - iTyp.convert(i, Multiplicity.REQUIRED) -} - -typedInstances.foreach { i => - println(i) -} - } - - @Test(expectedExceptions = Array(classOf[AtlasException]) , expectedExceptionsMessageRegExp = "A multiplicty of more than one requires a collection type for attribute 'stringSet'") - def WrongMultiplicity { -val b = new TypesBuilder -import b._ -val tDef = types { - _class("Wrong") { -"name" ~ (string, required) -"stringSet" ~ (string, multiplicty(0, Int.MaxValue, true)) - } -} -TypeSystem.getInstance().defineTypes(tDef) - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/src/test/scala/org/apache/atlas/typesystem/builders/TypesBuilderTest.scala -- diff --git a/typesystem/src/test/scala/org/apache/atlas/typesystem/builders/TypesBuilderTest.scala b/typesystem/src/test/scala/org/apache/atlas/typesystem/builders/TypesBuilderTest.scala deleted file mode 100644 index d01adb4..000 --- a/typesystem/src/test/scala/org/apache/atlas/typesystem/builders/TypesBuilderTest.scala +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed wit
[21/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/java/org/apache/atlas/query/QueryProcessorTest.java -- diff --git a/repository/src/test/java/org/apache/atlas/query/QueryProcessorTest.java b/repository/src/test/java/org/apache/atlas/query/QueryProcessorTest.java deleted file mode 100644 index 57bc74f..000 --- a/repository/src/test/java/org/apache/atlas/query/QueryProcessorTest.java +++ /dev/null @@ -1,157 +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.query; - -import com.google.common.collect.ImmutableSet; -import org.apache.atlas.AtlasException; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.DataTypes; -import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; -import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition; -import org.apache.atlas.typesystem.types.IDataType; -import org.apache.atlas.typesystem.types.TypeSystem; -import org.apache.atlas.typesystem.types.cache.DefaultTypeCache; -import org.testng.annotations.Test; -import scala.util.Either; -import scala.util.parsing.combinator.Parsers; - -import java.util.HashSet; -import java.util.Set; - -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef; -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -/** - * Tests the logic for skipping type cache lookup for things that - * cannot be types. - * - */ -public class QueryProcessorTest { - - -@Test -public void testAliasesNotTreatedAsTypes() throws Exception { - -ValidatingTypeCache tc = findTypeLookupsDuringQueryParsing("hive_db as inst where inst.name=\"Reporting\" select inst as id, inst.name"); -assertTrue(tc.wasTypeRequested("hive_db")); -assertFalse(tc.wasTypeRequested("inst")); -assertFalse(tc.wasTypeRequested("name")); - -} - - -@Test -public void testFieldInComparisionNotTreatedAsType() throws Exception { - -//test when the IdExpression is on the left, on the right, and on both sides of the ComparsionExpression -ValidatingTypeCache tc = findTypeLookupsDuringQueryParsing("hive_db where name=\"Reporting\" or \"Reporting\" = name or name=name"); -assertTrue(tc.wasTypeRequested("hive_db")); -assertFalse(tc.wasTypeRequested("name")); - -} - - -@Test -public void testFieldInArithmeticExprNotTreatedAsType() throws Exception { - -//test when the IdExpression is on the left, on the right, and on both sides of the ArithmeticExpression -ValidatingTypeCache tc = findTypeLookupsDuringQueryParsing("hive_db where (tableCount + 3) > (tableCount + tableCount) select (3 + tableCount) as updatedCount"); - -assertTrue(tc.wasTypeRequested("hive_db")); -assertFalse(tc.wasTypeRequested("tableCount")); -assertFalse(tc.wasTypeRequested("updatedCount")); - -} - -@Test -public void testFieldInSelectListWithAlasNotTreatedAsType() throws Exception { - -ValidatingTypeCache tc = findTypeLookupsDuringQueryParsing("hive_db select name as theName"); -assertTrue(tc.wasTypeRequested("hive_db")); -assertFalse(tc.wasTypeRequested("theName")); -assertFalse(tc.wasTypeRequested("name")); - -} - -@Test -public void testFieldInSelectListNotTreatedAsType() throws Exception { - - -ValidatingTypeCache tc = findTypeLookupsDuringQueryParsing("hive_db select name"); -assertTrue(tc.wasTypeRequested("hive_db")); -assertFalse(tc.wasTypeRequested("name")); - -} - -private ValidatingTypeCache findTypeLookupsDuringQueryParsing(String query) throws AtlasException { -TypeSystem typeSystem = TypeSystem.getInstance(); -ValidatingTypeCache result = new ValidatingTypeCache(); -typeSystem.setTypeCache(result); -typeSystem.reset(); -HierarchicalTypeDefinition hiveTypeDef = createClassTypeDef("hive_db", "", ImmutableSet.of(), -createRequiredAttrDef("nam
[14/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/scala/org/apache/atlas/query/ExpressionTest.scala -- diff --git a/repository/src/test/scala/org/apache/atlas/query/ExpressionTest.scala b/repository/src/test/scala/org/apache/atlas/query/ExpressionTest.scala deleted file mode 100755 index 918f327..000 --- a/repository/src/test/scala/org/apache/atlas/query/ExpressionTest.scala +++ /dev/null @@ -1,172 +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.query - -import org.apache.atlas.DBSandboxer -import org.apache.atlas.query.Expressions._ -import org.apache.atlas.repository.BaseTest -import org.testng.annotations.{BeforeMethod, Listeners, Test} - -class ExpressionTest extends BaseTest { - -@BeforeMethod -override def setup { -super.setup - -QueryTestsUtils.setupTypes - -} - -@Test def testClass: Unit = { -val e = QueryProcessor.validate(_class("DB")) -println(e) -} - -@Test def testFilter: Unit = { -val e = QueryProcessor.validate(_class("DB").where(id("name").`=`(string("Reporting" -println(e) -} - -@Test def testSelect: Unit = { -val e = QueryProcessor.validate(_class("DB").where(id("name").`=`(string("Reporting"))). -select(id("name"), id("owner"))) -println(e) -} - -@Test def testNegTypeTest: Unit = { -try { -val e = QueryProcessor.validate(_class("DB").where(id("name"))) -println(e) -} catch { -case e: ExpressionException if e.getMessage.endsWith("expression: DB where name") => () -} -} - -@Test def testIsTrait: Unit = { -val e = QueryProcessor.validate(_class("DB").where(isTrait("JdbcAccess"))) -println(e) -} - -@Test def testIsTraitNegative: Unit = { -try { -val e = QueryProcessor.validate(_class("DB").where(isTrait("Jdb"))) -println(e) -} catch { -case e: ExpressionException if e.getMessage.endsWith("not a TraitType, expression: is Jdb") => () -} -} - -@Test def testhasField: Unit = { -val e = QueryProcessor.validate(_class("DB").where(hasField("name"))) -println(e) -} - -@Test def testHasFieldNegative: Unit = { -try { -val e = QueryProcessor.validate(_class("DB").where(hasField("nam"))) -println(e) -} catch { -case e: ExpressionException if e.getMessage.endsWith("not a TraitType, expression: is Jdb") => () -} -} - -@Test def testFieldReference: Unit = { -val e = QueryProcessor.validate(_class("DB").field("Table")) -println(e) -} - -@Test def testNegFieldReference: Unit = { -try { -val e = QueryProcessor.validate(_class("DB").where(_class("LoadProcess").hasField("name"))) -println(e) -} catch { -case e: ExpressionException -if e.getMessage.endsWith("srcType of field doesn't match input type, expression: LoadProcess has name") => () -} -} - -@Test def testFieldReferenceRedundant: Unit = { -val e = QueryProcessor.validate(_class("DB").where(_class("DB").hasField("name"))) -println(e) -} - -@Test def testBackReference: Unit = { -val e = QueryProcessor.validate( - _class("DB").as("db1").field("Table").where(id("db1").field("name").`=`(string("Reporting" -println(e) -} - -@Test def testArith: Unit = { -val e = QueryProcessor.validate(_class("DB").where(id("name").`=`(string("Reporting"))). -select(id("name"), id("createTime") + int(1))) -println(e) -} - -@Test def testComparisonLogical: Unit = { -val e = QueryProcessor.validate(_class("DB").where(id("name").`=`(string("Reporting")). -and(id("createTime") + int(1) > int(0 -println(e) -} - -@Test def testJoinAndSelect1: Unit = { -val e = QueryProcessor.validate( - _class("DB").as("db1").field("Table").as("tab").where((id("
[03/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java -- diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java index d7c66d3..ff1751d 100755 --- a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java @@ -22,8 +22,6 @@ import com.google.common.base.Preconditions; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasConfiguration; import org.apache.atlas.classification.InterfaceAudience; -import org.apache.atlas.discovery.DiscoveryException; -import org.apache.atlas.discovery.DiscoveryService; import org.apache.atlas.query.QueryParams; import org.apache.atlas.utils.AtlasPerfTracer; import org.apache.atlas.utils.ParamChecker; @@ -46,6 +44,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -65,8 +64,6 @@ public class MetadataDiscoveryResource { private static final String QUERY_TYPE_FULLTEXT = "full-text"; private static final String LIMIT_OFFSET_DEFAULT = "-1"; -private final DiscoveryService discoveryService; - private final boolean gremlinSearchEnabled; private static Configuration applicationProperties = null; private static final String ENABLE_GREMLIN_SEARCH_PROPERTY = "atlas.search.gremlin.enable"; @@ -75,11 +72,10 @@ public class MetadataDiscoveryResource { * Created by the Guice ServletModule and injected with the * configured DiscoveryService. * - * @param discoveryService metadata service handle + * @param configuration configuration */ @Inject -public MetadataDiscoveryResource(DiscoveryService discoveryService, Configuration configuration) { -this.discoveryService = discoveryService; +public MetadataDiscoveryResource(Configuration configuration) { applicationProperties = configuration; gremlinSearchEnabled = applicationProperties != null && applicationProperties.getBoolean(ENABLE_GREMLIN_SEARCH_PROPERTY, false); } @@ -152,12 +148,12 @@ public class MetadataDiscoveryResource { dslQuery = ParamChecker.notEmpty(dslQuery, "dslQuery cannot be null"); QueryParams queryParams = validateQueryParams(limit, offset); -final String jsonResultStr = discoveryService.searchByDSL(dslQuery, queryParams); +final String jsonResultStr = ""; // TODO-typeSystem-removal: discoveryService.searchByDSL(dslQuery, queryParams); JSONObject response = new DSLJSONResponseBuilder().results(jsonResultStr).query(dslQuery).build(); return Response.ok(response).build(); -} catch (DiscoveryException | IllegalArgumentException e) { +} catch (IllegalArgumentException e) { LOG.error("Unable to get entity list for dslQuery {}", dslQuery, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (WebApplicationException e) { @@ -220,11 +216,11 @@ public class MetadataDiscoveryResource { } if (!gremlinSearchEnabled) { -throw new DiscoveryException("Gremlin search is not enabled."); +throw new Exception("Gremlin search is not enabled."); } gremlinQuery = ParamChecker.notEmpty(gremlinQuery, "gremlinQuery cannot be null or empty"); -final List> results = discoveryService.searchByGremlin(gremlinQuery); +final List> results = new ArrayList<>(); // TODO-typeSystem-removal: discoveryService.searchByGremlin(gremlinQuery); JSONObject response = new JSONObject(); response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId()); @@ -239,7 +235,7 @@ public class MetadataDiscoveryResource { response.put(AtlasClient.COUNT, list.length()); return Response.ok(response).build(); -} catch (DiscoveryException | IllegalArgumentException e) { +} catch (IllegalArgumentException e) { LOG.error("Unable to get entity list for gremlinQuery {}", gremlinQuery, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (WebApplicationException e) { @@ -284,12 +280,12 @@ public class MetadataDiscoveryResource { query = ParamChecker.notEmpty(query, "query cannot be null or empty"); QueryParams queryParams = validateQueryParams(limit, offset); -final String jsonResult
[13/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala -- diff --git a/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala b/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala deleted file mode 100755 index b01cbf8..000 --- a/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala +++ /dev/null @@ -1,541 +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.query - -import org.apache.atlas.{DBSandboxer, TestUtils} -import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy -import org.apache.atlas.query.Expressions._class -import org.apache.atlas.query.Expressions.id -import org.apache.atlas.query.Expressions.int -import org.apache.atlas.repository.graph.AtlasGraphProvider -import org.apache.atlas.repository.graph.GraphBackedMetadataRepository -import org.apache.atlas.repository.graphdb.AtlasGraph -import org.apache.atlas.typesystem.types.TypeSystem -import org.testng.annotations._ - -class LineageQueryTest extends BaseGremlinTest { - -var g: AtlasGraph[_,_] = null -var gp:GraphPersistenceStrategies = null; - -@BeforeMethod -def resetRequestContext() { -TestUtils.resetRequestContext() -} - - -@BeforeClass -def beforeAll() { -TypeSystem.getInstance().reset() -var repo = new GraphBackedMetadataRepository(null, new AtlasGraphProvider().get()); -TestUtils.setupGraphProvider(repo); -//force graph to be initialized first -AtlasGraphProvider.getGraphInstance(); - -//create types and indices up front. Without this, some of the property keys (particularly __traitNames and __superTypes) -//get ended up created implicitly with some graph backends with the wrong multiplicity. This also makes the queries -//we execute perform better :-) - QueryTestsUtils.setupTypesAndIndices() - - gp = new DefaultGraphPersistenceStrategy(repo); - g = QueryTestsUtils.setupTestGraph(repo) -} - -@AfterClass -def afterAll() { -AtlasGraphProvider.cleanup() -} - -val PREFIX_SPACES_REGEX = ("\\n\\s*").r - - @Test def testInputTables { -val r = QueryProcessor.evaluate(_class("LoadProcess").field("inputTables"), g, gp) -val x = r.toJson -validateJson(r,"""{ - | "query":"LoadProcess inputTables", - | "dataType":{ - |"superTypes":[ - | - |], - | "hierarchicalMetaTypeName":"org.apache.atlas.typesystem.types.ClassType", - |"typeName":"Table", - |"attributeDefinitions":[ - | { - |"name":"name", - |"dataTypeName":"string", - |"multiplicity":{ - | "lower":0, - | "upper":1, - | "isUnique":false - |}, - |"isComposite":false, - |"isUnique":false, - |"isIndexable":false, - |"reverseAttributeName":null - | }, - | { - |"name":"db", - |"dataTypeName":"DB", - |"multiplicity":{ - | "lower":1, - | "upper":1, - | "isUnique":false - |}, - |"isComposite":false, - |"isUnique":false, - |"isIndexable":false, - |"reverseAttributeName":null - | }, -
[09/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java -- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java deleted file mode 100755 index 036d18d..000 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ObjectGraphWalker.java +++ /dev/null @@ -1,226 +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.typesystem.types; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import org.apache.atlas.AtlasException; -import org.apache.atlas.typesystem.IReferenceableInstance; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.persistence.Id; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; - -/** - * Given a IReferenceableInstance, a Walker will traverse the Object Graph - * reachable form the instance. It will invoke the process call on the provided NodeProcessor - * for each non-primitive attribute (Structs, Traits, References, Arrays of Non-Primitives, Maps - * of Non-Primitives) - */ -public class ObjectGraphWalker { - -final Queue queue; -final TypeSystem typeSystem; -final NodeProcessor nodeProcessor; -Set processedIds; - -public ObjectGraphWalker(TypeSystem typeSystem, NodeProcessor nodeProcessor) throws AtlasException { -this(typeSystem, nodeProcessor, (IReferenceableInstance) null); -} - -public ObjectGraphWalker(TypeSystem typeSystem, NodeProcessor nodeProcessor, IReferenceableInstance start) -throws AtlasException { -this.typeSystem = typeSystem; -this.nodeProcessor = nodeProcessor; -queue = new LinkedList<>(); -processedIds = new HashSet<>(); -if (start != null) { -visitReferenceableInstance(start); -} -} - -public ObjectGraphWalker(TypeSystem typeSystem, NodeProcessor nodeProcessor, -List roots) throws AtlasException { -this.typeSystem = typeSystem; -this.nodeProcessor = nodeProcessor; -queue = new LinkedList<>(); -processedIds = new HashSet<>(); -for (IReferenceableInstance r : roots) { -visitReferenceableInstance(r); -} -} - -public void walk() throws AtlasException { -while (!queue.isEmpty()) { -IReferenceableInstance r = queue.poll(); -if(r != null) { -processReferenceableInstance(r); -} -} -} - -public void addRoot(IReferenceableInstance root) { -visitReferenceableInstance(root); -} - -void traverseValue(IDataType dT, Object val) throws AtlasException { -if (val != null) { -if (dT.getTypeCategory() == DataTypes.TypeCategory.ARRAY) { -IDataType elemType = ((DataTypes.ArrayType) dT).getElemType(); -visitCollection(elemType, val); -} else if (dT.getTypeCategory() == DataTypes.TypeCategory.MAP) { -IDataType keyType = ((DataTypes.MapType) dT).getKeyType(); -IDataType valueType = ((DataTypes.MapType) dT).getValueType(); -visitMap(keyType, valueType, val); -} else if (dT.getTypeCategory() == DataTypes.TypeCategory.STRUCT -|| dT.getTypeCategory() == DataTypes.TypeCategory.TRAIT) { -visitStruct(val); -} else if (dT.getTypeCategory() == DataTypes.TypeCategory.CLASS) { -visitReferenceableInstance(val); -} -} -} - -void visitMap(IDataType keyType, IDataType valueType, Object val) throws AtlasException { -if (keyType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE -&& valueType.getTypeCategory() == DataTypes.TypeCategory.PRIMITIVE) { -return; -
[06/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeInheritanceTest.java -- diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeInheritanceTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeInheritanceTest.java deleted file mode 100644 index c13ef3a..000 --- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeInheritanceTest.java +++ /dev/null @@ -1,252 +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.typesystem.types; - -import com.google.common.collect.ImmutableSet; - -import org.apache.atlas.AtlasException; -import org.apache.atlas.typesystem.IStruct; -import org.apache.atlas.typesystem.ITypedInstance; -import org.apache.atlas.typesystem.ITypedStruct; -import org.apache.atlas.typesystem.Struct; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef; -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef; -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef; -import static org.apache.atlas.typesystem.types.utils.TypesUtil.createTraitTypeDef; - -/** - * Unit tests for type inheritance. - */ -public class TypeInheritanceTest extends BaseTest { - -@BeforeMethod -public void setup() throws Exception { -TypeSystem.getInstance().reset(); -super.setup(); -} - -/* - * Type Hierarchy is: - * A(a) - * B(b) extends A - */ -@Test -public void testSimpleInheritance() throws AtlasException { -HierarchicalTypeDefinition A = createClassTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE)); - -HierarchicalTypeDefinition B = -createClassTypeDef("B", ImmutableSet.of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - -defineClasses(A, B); - -ClassType BType = getTypeSystem().getDataType(ClassType.class, "B"); - -Struct s1 = new Struct("B"); -s1.set("b", true); -s1.set("a", 1); - -ITypedInstance ts = BType.convert(s1, Multiplicity.REQUIRED); -Assert.assertEquals(ts.toString(), "{\n" + -"\tid : (type: B, id: )\n" + -"\tb : \ttrue\n" + -"\ta : \t1\n" + -"}"); -} - -/* - * Type Hierarchy is: - * A(a, b) - * B(b) extends A - */ -@Test -public void testSimpleInheritanceWithOverrides() throws AtlasException { -HierarchicalTypeDefinition A = createClassTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE), -createRequiredAttrDef("b", DataTypes.BOOLEAN_TYPE)); - -HierarchicalTypeDefinition B = -createClassTypeDef("B", ImmutableSet.of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - -defineClasses(A, B); - -ClassType BType = getTypeSystem().getDataType(ClassType.class, "B"); - -Struct s1 = new Struct("B"); -s1.set("b", true); -s1.set("a", 1); -s1.set("A.B.b", false); - -ITypedInstance ts = BType.convert(s1, Multiplicity.REQUIRED); -Assert.assertEquals(ts.toString(), "{\n" + -"\tid : (type: B, id: )\n" + -"\tb : \ttrue\n" + -"\ta : \t1\n" + -"\tA.B.b : \tfalse\n" + -"}"); -} - -/* - * Type Hierarchy is: - * A(a) - * B(b) extends A - * C(c) extends B - * D(d) extends C - */ -@Test -public void testMultiLevelInheritance() throws AtlasException { -HierarchicalTypeDefinition A = createClassTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE)); - -HierarchicalTypeDefinition B = -createClassTypeDef("B", ImmutableSet.of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - -HierarchicalTypeDefinition C = -createClassTypeDef("C", Imm
[01/42] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
Repository: atlas Updated Branches: refs/heads/master 0abf84caa -> 435fe3fba http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java -- diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java index a13f069..f25fc5f 100755 --- a/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/integration/MetadataDiscoveryJerseyResourceIT.java @@ -18,23 +18,16 @@ package org.apache.atlas.web.integration; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.core.util.MultivaluedMapImpl; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasServiceException; -import org.apache.atlas.typesystem.Referenceable; -import org.apache.atlas.typesystem.Struct; -import org.apache.atlas.typesystem.TypesDef; -import org.apache.atlas.typesystem.persistence.Id; -import org.apache.atlas.typesystem.types.ClassType; -import org.apache.atlas.typesystem.types.DataTypes; -import org.apache.atlas.typesystem.types.EnumTypeDefinition; -import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition; -import org.apache.atlas.typesystem.types.StructTypeDefinition; -import org.apache.atlas.typesystem.types.TraitType; -import org.apache.atlas.typesystem.types.utils.TypesUtil; +import org.apache.atlas.model.typedef.AtlasBaseTypeDef; +import org.apache.atlas.v1.model.instance.Id; +import org.apache.atlas.v1.model.instance.Referenceable; +import org.apache.atlas.v1.model.instance.Struct; +import org.apache.atlas.v1.model.typedef.*; +import org.apache.atlas.v1.typesystem.types.utils.TypesUtil; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONObject; import org.testng.Assert; @@ -42,6 +35,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import javax.ws.rs.core.MultivaluedMap; +import java.util.Collections; import java.util.List; import static org.testng.Assert.assertEquals; @@ -236,16 +230,16 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { private void createTypes() throws Exception { createTypeDefinitionsV1(); -HierarchicalTypeDefinition dslTestTypeDefinition = TypesUtil -.createClassTypeDef("dsl_test_type", ImmutableSet.of(), -TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), -TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE)); +ClassTypeDefinition dslTestTypeDefinition = TypesUtil +.createClassTypeDef("dsl_test_type", null, Collections.emptySet(), +TypesUtil.createUniqueRequiredAttrDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING), +TypesUtil.createRequiredAttrDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING)); -HierarchicalTypeDefinition classificationTraitDefinition = TypesUtil -.createTraitTypeDef("Classification", ImmutableSet.of(), -TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE)); -TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.of(), ImmutableList.of(), -ImmutableList.of(classificationTraitDefinition), ImmutableList.of(dslTestTypeDefinition)); +TraitTypeDefinition classificationTraitDefinition = TypesUtil +.createTraitTypeDef("Classification", null, Collections.emptySet(), +TypesUtil.createRequiredAttrDef("tag", AtlasBaseTypeDef.ATLAS_TYPE_STRING)); +TypesDef typesDef = new TypesDef(Collections.emptyList(), Collections.emptyList(), +Collections.singletonList(classificationTraitDefinition), Collections.singletonList(dslTestTypeDefinition)); createType(typesDef); } @@ -259,7 +253,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { tagName = randomString(); traitInstance.set("tag", tagName); -List traits = entityInstance.getTraits(); +List traits = entityInstance.getTraitNames(); assertEquals(traits.size(), 1); return createInstance(entityInstance); http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java -- diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/Typedefs