You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sh...@apache.org on 2016/08/01 04:04:57 UTC

incubator-atlas git commit: ATLAS-861 1 table out of 50, 000 tables is left unimported throwing exception during deserialization (sumasai via shwethags)

Repository: incubator-atlas
Updated Branches:
  refs/heads/master a4ceec90c -> 1c9b8b419


ATLAS-861 1 table out of 50,000 tables is left unimported throwing exception during deserialization (sumasai via shwethags)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/1c9b8b41
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/1c9b8b41
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/1c9b8b41

Branch: refs/heads/master
Commit: 1c9b8b4191390b5024596bbe15d657b3bf84eb78
Parents: a4ceec9
Author: Shwetha GS <ss...@hortonworks.com>
Authored: Mon Aug 1 09:34:48 2016 +0530
Committer: Shwetha GS <ss...@hortonworks.com>
Committed: Mon Aug 1 09:34:48 2016 +0530

----------------------------------------------------------------------
 release-log.txt                                 |  1 +
 .../atlas/typesystem/types/DataTypes.java       | 14 ++++++++-----
 .../atlas/typesystem/types/TypeSystemTest.java  | 21 ++++++++++++++++++++
 3 files changed, 31 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1c9b8b41/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 18c9173..c21b43a 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
 
 
 ALL CHANGES:
+ATLAS-861 1 table out of 50,000 tables is left unimported throwing exception during deserialization (sumasai via shwethags)
 ATLAS-1065 UI: Full text search view same as DSL's (kevalbhat18 via shwethags)
 ATLAS-1066 Falcon fails to post entity to Atlas due to kafka exception (mneethiraj via shwethags)
 ATLAS-1064 UI: Pagination for full text search results (Kalyanikashikar via shwethags)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1c9b8b41/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
index 3783c23..425e163 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java
@@ -22,17 +22,19 @@ 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.text.ParseException;
 import java.util.Collection;
 import java.util.Date;
 import java.util.Iterator;
@@ -405,6 +407,8 @@ public class DataTypes {
             super(name, null);
         }
 
+        private static final DateTimeFormatter utcDateFormat = ISODateTimeFormat.dateTime();
+
         @Override
         public Date convert(Object val, Multiplicity m) throws AtlasException {
             if (val != null) {
@@ -412,8 +416,8 @@ public class DataTypes {
                     return (Date) val;
                 } else if (val instanceof String) {
                     try {
-                        return TypeSystem.getInstance().getDateFormat().parse((String) val);
-                    } catch (ParseException ne) {
+                        return utcDateFormat.parseDateTime((String)val).toDate();
+                    } catch (Exception ne) {
                         throw new ValueConversionException(this, val, ne);
                     }
                 } else if (val instanceof Number) {
@@ -427,7 +431,7 @@ public class DataTypes {
 
         @Override
         public void output(Date val, Appendable buf, String prefix, Set<Date> inProcess) throws AtlasException {
-            TypeUtils.outputVal(val == null ? "<null>" : TypeSystem.getInstance().getDateFormat().format(val), buf,
+            TypeUtils.outputVal(val == null ? "<null>" : utcDateFormat.print(new DateTime(val).withZone(DateTimeZone.UTC)), buf,
                     prefix);
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1c9b8b41/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
----------------------------------------------------------------------
diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
index 4a285a6..96946ea 100755
--- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
+++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
@@ -33,7 +33,9 @@ import org.testng.annotations.Test;
 import scala.actors.threadpool.Arrays;
 
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 
 import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
@@ -46,6 +48,9 @@ import static org.testng.Assert.fail;
 
 public class TypeSystemTest extends BaseTest {
 
+    public static final long TEST_DATE_IN_LONG = 1418265358440L;
+    public static final String TEST_DATE_STRING = "2014-12-11T02:35:58.440Z";
+
     @BeforeClass
     public void setUp() throws Exception {
         super.setup();
@@ -284,4 +289,20 @@ public class TypeSystemTest extends BaseTest {
             //expected
         }
     }
+
+    @Test(expectedExceptions = ValueConversionException.class)
+    public void testConvertInvalidDate() throws Exception {
+       DataTypes.DATE_TYPE.convert("", Multiplicity.OPTIONAL);
+    }
+
+    @Test()
+    public void testConvertValidDate() throws Exception {
+        Date date = DataTypes.DATE_TYPE.convert(TEST_DATE_STRING, Multiplicity.OPTIONAL);
+        Assert.assertEquals(date, new Date(TEST_DATE_IN_LONG));
+
+
+        StringBuilder buf = new StringBuilder();
+        DataTypes.DATE_TYPE.output(new Date(TEST_DATE_IN_LONG), buf, "", new HashSet<Date>());
+        Assert.assertEquals(buf.toString(), TEST_DATE_STRING);
+    }
 }