http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/ABridge.java ---------------------------------------------------------------------- diff --git a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/ABridge.java b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/ABridge.java index 3873b6b..6559b72 100755 --- a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/ABridge.java +++ b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/ABridge.java @@ -41,19 +41,15 @@ import java.util.Map.Entry; public abstract class ABridge implements IBridge { protected static final Logger LOG = BridgeManager.LOG; - protected ArrayList<Class<? extends AEntityBean>> typeBeanClasses - = new ArrayList<Class<? extends AEntityBean>>(); + protected ArrayList<Class<? extends AEntityBean>> typeBeanClasses = new ArrayList<Class<? extends AEntityBean>>(); MetadataRepository repo; protected ABridge(MetadataRepository repo) { this.repo = repo; } - protected HierarchicalTypeDefinition<ClassType> createClassTypeDef(String name, - ImmutableList<String> - superTypes, - AttributeDefinition... - attrDefs) { + protected HierarchicalTypeDefinition<ClassType> createClassTypeDef(String name, ImmutableList<String> superTypes, + AttributeDefinition... attrDefs) { return new HierarchicalTypeDefinition(ClassType.class, name, superTypes, attrDefs); } @@ -67,11 +63,10 @@ public abstract class ABridge implements IBridge { // turn into a HiveLineageBean try { Class<AEntityBean> c = getTypeBeanInListByName(ref.getTypeName()); - return this.convertFromITypedReferenceable(ref, - getTypeBeanInListByName(ref.getTypeName())); + return this.convertFromITypedReferenceable(ref, getTypeBeanInListByName(ref.getTypeName())); } catch (BridgeException | InstantiationException | IllegalAccessException | - IllegalArgumentException | InvocationTargetException | NoSuchMethodException | - SecurityException e) { + IllegalArgumentException | InvocationTargetException | NoSuchMethodException | + SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -80,8 +75,7 @@ public abstract class ABridge implements IBridge { public String create(AEntityBean bean) throws MetadataException { - ClassType type = TypeSystem.getInstance() - .getDataType(ClassType.class, bean.getClass().getSimpleName()); + ClassType type = TypeSystem.getInstance().getDataType(ClassType.class, bean.getClass().getSimpleName()); ITypedReferenceableInstance refBean = null; try { refBean = type.convert(this.convertToReferencable(bean), Multiplicity.REQUIRED); @@ -140,10 +134,10 @@ public abstract class ABridge implements IBridge { return selfAware; } - protected final <T extends AEntityBean> T convertFromITypedReferenceable( - ITypedReferenceableInstance instance, Class<? extends AEntityBean> c) - throws InstantiationException, IllegalAccessException, IllegalArgumentException, - InvocationTargetException, NoSuchMethodException, SecurityException, BridgeException { + protected final <T extends AEntityBean> T convertFromITypedReferenceable(ITypedReferenceableInstance instance, + Class<? extends AEntityBean> c) + throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, + NoSuchMethodException, SecurityException, BridgeException { if (!instance.getTypeName().equals(c.getSimpleName())) { throw new BridgeException("ReferenceableInstance type not the same as bean"); } @@ -151,10 +145,8 @@ public abstract class ABridge implements IBridge { for (Entry<String, AttributeInfo> e : instance.fieldMapping().fields.entrySet()) { try { - String convertedName = e.getKey().substring(0, 1).toUpperCase() + - e.getKey().substring(1); - this.getClass().getMethod("set" + convertedName, - Class.forName(e.getValue().dataType().getName())) + String convertedName = e.getKey().substring(0, 1).toUpperCase() + e.getKey().substring(1); + this.getClass().getMethod("set" + convertedName, Class.forName(e.getValue().dataType().getName())) .invoke(this, instance.get(e.getKey())); } catch (MetadataException | ClassNotFoundException e1) { // TODO Auto-generated catch block
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeManager.java ---------------------------------------------------------------------- diff --git a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeManager.java b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeManager.java index 7973c43..036c24d 100755 --- a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeManager.java +++ b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeManager.java @@ -50,13 +50,12 @@ public class BridgeManager { @Inject BridgeManager(MetadataRepository rs) - throws ConfigurationException, ClassNotFoundException, InstantiationException, - IllegalAccessException, IllegalArgumentException, InvocationTargetException, - NoSuchMethodException, SecurityException { + throws ConfigurationException, ClassNotFoundException, InstantiationException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { this.ts = TypeSystem.getInstance(); this.rs = rs; - if (System.getProperty("bridgeManager.propsFile") != null && - System.getProperty("bridgeManager.propsFile").length() != 0) { + if (System.getProperty("bridgeManager.propsFile") != null + && System.getProperty("bridgeManager.propsFile").length() != 0) { setActiveBridges(System.getProperty("bridgeManager.propsFile")); } else { setActiveBridges(bridgeFileDefault); @@ -73,8 +72,7 @@ public class BridgeManager { } - public final static HierarchicalTypeDefinition<ClassType> - convertEntityBeanToClassTypeDefinition( + public final static HierarchicalTypeDefinition<ClassType> convertEntityBeanToClassTypeDefinition( Class<? extends AEntityBean> class1) { ArrayList<AttributeDefinition> attDefAL = new ArrayList<AttributeDefinition>(); for (Field f : class1.getFields()) { @@ -87,18 +85,16 @@ public class BridgeManager { } } - HierarchicalTypeDefinition<ClassType> typeDef = new HierarchicalTypeDefinition<>( - ClassType.class, class1.getSimpleName(), - null, (AttributeDefinition[]) attDefAL.toArray(new AttributeDefinition[0])); + HierarchicalTypeDefinition<ClassType> typeDef = + new HierarchicalTypeDefinition<>(ClassType.class, class1.getSimpleName(), null, + (AttributeDefinition[]) attDefAL.toArray(new AttributeDefinition[0])); return typeDef; } - public final static AttributeDefinition convertFieldtoAttributeDefiniton(Field f) - throws MetadataException { + public final static AttributeDefinition convertFieldtoAttributeDefiniton(Field f) throws MetadataException { - return new AttributeDefinition(f.getName(), f.getType().getSimpleName(), - Multiplicity.REQUIRED, false, null); + return new AttributeDefinition(f.getName(), f.getType().getSimpleName(), Multiplicity.REQUIRED, false, null); } public ArrayList<ABridge> getActiveBridges() { @@ -116,8 +112,7 @@ public class BridgeManager { try { BridgeManager.LOG.info("Loading : Active Bridge List"); config.load(bridgePropFileName); - String[] activeBridgeList = ((String) config.getProperty("BridgeManager.activeBridges")) - .split(","); + String[] activeBridgeList = ((String) config.getProperty("BridgeManager.activeBridges")).split(","); BridgeManager.LOG.info("Loaded : Active Bridge List"); BridgeManager.LOG.info("First Loaded :" + activeBridgeList[0]); @@ -125,8 +120,7 @@ public class BridgeManager { Class<?> bridgeCls = (Class<?>) Class.forName(s); if (ABridge.class.isAssignableFrom(bridgeCls)) { System.out.println(s + " is able to be instaciated"); - aBList.add((ABridge) bridgeCls.getConstructor(MetadataRepository.class) - .newInstance(rs)); + aBList.add((ABridge) bridgeCls.getConstructor(MetadataRepository.class).newInstance(rs)); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeTypeBootstrapper.java ---------------------------------------------------------------------- diff --git a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeTypeBootstrapper.java b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeTypeBootstrapper.java index a0bb2a8..3cdd2d2 100755 --- a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeTypeBootstrapper.java +++ b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/BridgeTypeBootstrapper.java @@ -40,44 +40,39 @@ public class BridgeTypeBootstrapper { private boolean isSetup = false; @Inject - BridgeTypeBootstrapper(Map<Class, IBridge> bridges) - throws MetadataException { + BridgeTypeBootstrapper(Map<Class, IBridge> bridges) throws MetadataException { this.bridges = bridges; } - public final static HierarchicalTypeDefinition<ClassType> - convertEntityBeanToClassTypeDefinition( + public final static HierarchicalTypeDefinition<ClassType> convertEntityBeanToClassTypeDefinition( Class<? extends AEntityBean> class1) { ArrayList<AttributeDefinition> attDefAL = new ArrayList<AttributeDefinition>(); for (Field f : class1.getFields()) { try { attDefAL.add(BridgeTypeBootstrapper.convertFieldtoAttributeDefiniton(f)); } catch (MetadataException e) { - BridgeManager.LOG.error("Class " + class1.getName() - + " cannot be converted to TypeDefinition"); + BridgeManager.LOG.error("Class " + class1.getName() + " cannot be converted to TypeDefinition"); e.printStackTrace(); } } - HierarchicalTypeDefinition<ClassType> typeDef = new HierarchicalTypeDefinition<>( - ClassType.class, class1.getSimpleName(), null, - (AttributeDefinition[]) attDefAL - .toArray(new AttributeDefinition[0])); + HierarchicalTypeDefinition<ClassType> typeDef = + new HierarchicalTypeDefinition<>(ClassType.class, class1.getSimpleName(), null, + (AttributeDefinition[]) attDefAL.toArray(new AttributeDefinition[0])); return typeDef; } - public final static AttributeDefinition convertFieldtoAttributeDefiniton( - Field f) throws MetadataException { + public final static AttributeDefinition convertFieldtoAttributeDefiniton(Field f) throws MetadataException { - return new AttributeDefinition(f.getName(), - f.getType().getSimpleName().toLowerCase(), Multiplicity.REQUIRED, false, null); + return new AttributeDefinition(f.getName(), f.getType().getSimpleName().toLowerCase(), Multiplicity.REQUIRED, + false, null); } public synchronized boolean bootstrap() throws MetadataException { - if (isSetup) + if (isSetup) { return false; - else { + } else { LOG.info("Bootstrapping types"); _bootstrap(); isSetup = true; @@ -94,12 +89,10 @@ public class BridgeTypeBootstrapper { } } - private final boolean loadTypes(IBridge bridge, TypeSystem ts) - throws MetadataException { + private final boolean loadTypes(IBridge bridge, TypeSystem ts) throws MetadataException { for (Class<? extends AEntityBean> clazz : bridge.getTypeBeanClasses()) { LOG.info("Registering %s", clazz.getSimpleName()); - ts.defineClassType(BridgeTypeBootstrapper - .convertEntityBeanToClassTypeDefinition(clazz)); + ts.defineClassType(BridgeTypeBootstrapper.convertEntityBeanToClassTypeDefinition(clazz)); } return false; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveMetaImporter.java ---------------------------------------------------------------------- diff --git a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveMetaImporter.java b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveMetaImporter.java index a8dd8b7..e85014d 100755 --- a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveMetaImporter.java +++ b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveMetaImporter.java @@ -79,8 +79,7 @@ public class HiveMetaImporter { public static boolean databasesImport() throws MetaException, RepositoryException { ClassType classType = null; try { - classType = TypeSystem.getInstance() - .getDataType(ClassType.class, HiveStructureBridge.DB_CLASS_TYPE); + classType = TypeSystem.getInstance().getDataType(ClassType.class, HiveStructureBridge.DB_CLASS_TYPE); } catch (MetadataException e1) { e1.printStackTrace(); } @@ -118,8 +117,7 @@ public class HiveMetaImporter { public static boolean tablesImport(String dbName) throws MetaException, RepositoryException { ClassType classType = null; try { - classType = TypeSystem.getInstance() - .getDataType(ClassType.class, HiveStructureBridge.TB_CLASS_TYPE); + classType = TypeSystem.getInstance().getDataType(ClassType.class, HiveStructureBridge.TB_CLASS_TYPE); } catch (MetadataException e1) { e1.printStackTrace(); } @@ -129,8 +127,7 @@ public class HiveMetaImporter { return true; } - public static boolean tableImport(String dbName, String tbName) - throws MetaException, RepositoryException { + public static boolean tableImport(String dbName, String tbName) throws MetaException, RepositoryException { try { Table tb = msc.getTable(dbName, tbName); Referenceable tbRef = new Referenceable(HiveStructureBridge.TB_CLASS_TYPE); @@ -157,12 +154,10 @@ public class HiveMetaImporter { return true; } - public static boolean fieldsImport(String dbName, String tbName) - throws MetaException, RepositoryException { + public static boolean fieldsImport(String dbName, String tbName) throws MetaException, RepositoryException { ClassType classType = null; try { - classType = TypeSystem.getInstance() - .getDataType(ClassType.class, HiveStructureBridge.FD_CLASS_TYPE); + classType = TypeSystem.getInstance().getDataType(ClassType.class, HiveStructureBridge.FD_CLASS_TYPE); } catch (MetadataException e1) { e1.printStackTrace(); } @@ -190,8 +185,7 @@ public class HiveMetaImporter { return true; } - public static boolean fieldImport(String dbName, String tbName, String fdName) - throws MetaException { + public static boolean fieldImport(String dbName, String tbName, String fdName) throws MetaException { try { for (FieldSchema fs : msc.getFields(dbName, tbName)) { if (fs.getName().equals(fs)) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveStructureBridge.java ---------------------------------------------------------------------- diff --git a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveStructureBridge.java b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveStructureBridge.java index 2ec3af2..e9fb143 100755 --- a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveStructureBridge.java +++ b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/hivestructure/HiveStructureBridge.java @@ -45,60 +45,50 @@ public class HiveStructureBridge extends ABridge { } public boolean defineBridgeTypes(TypeSystem ts) { - ArrayList<HierarchicalTypeDefinition<?>> al - = new ArrayList<HierarchicalTypeDefinition<?>>(); + ArrayList<HierarchicalTypeDefinition<?>> al = new ArrayList<HierarchicalTypeDefinition<?>>(); // TODO //convert to helper methods // Add to arrayList try { - HierarchicalTypeDefinition<ClassType> databaseClassTypeDef - = new HierarchicalTypeDefinition<ClassType>("ClassType", DB_CLASS_TYPE, null, - new AttributeDefinition[]{ - new AttributeDefinition("DESC", "STRING_TYPE", Multiplicity.OPTIONAL, - false, null), - new AttributeDefinition("DB_LOCATION_URI", "STRING_TYPE", - Multiplicity.REQUIRED, false, null), - new AttributeDefinition("NAME", "STRING_TYPE", Multiplicity.REQUIRED, - false, null), - new AttributeDefinition("OWNER_TYPE", "STRING_TYPE", - Multiplicity.OPTIONAL, false, null), - new AttributeDefinition("OWNER_NAME", "STRING_TYPE", - Multiplicity.OPTIONAL, false, null) - } - ); - - HierarchicalTypeDefinition<ClassType> tableClassTypeDef - = new HierarchicalTypeDefinition<ClassType>("ClassType", TB_CLASS_TYPE, null, - new AttributeDefinition[]{ - new AttributeDefinition("CREATE_TIME", "LONG_TYPE", - Multiplicity.REQUIRED, false, null), - new AttributeDefinition("LAST_ACCESS_TIME", "LONG_TYPE", - Multiplicity.REQUIRED, false, null), - new AttributeDefinition("OWNER", "STRING_TYPE", Multiplicity.REQUIRED, - false, null), - new AttributeDefinition("TBL_NAME", "STRING_TYPE", - Multiplicity.REQUIRED, false, null), - new AttributeDefinition("TBL_TYPE", "STRING_TYPE", - Multiplicity.REQUIRED, false, null), - new AttributeDefinition("VIEW_EXPANDED_TEXT", "STRING_TYPE", - Multiplicity.OPTIONAL, false, null), - new AttributeDefinition("VIEW_ORIGINAL_TEXT", "STRING_TYPE", - Multiplicity.OPTIONAL, false, null) - } - ); - - HierarchicalTypeDefinition<ClassType> columnClassTypeDef - = new HierarchicalTypeDefinition<ClassType>("ClassType", FD_CLASS_TYPE, null, - new AttributeDefinition[]{ - new AttributeDefinition("COMMENT", "STRING_TYPE", Multiplicity.OPTIONAL, - false, null), - new AttributeDefinition("COLUMN_NAME", "STRING_TYPE", - Multiplicity.REQUIRED, false, null), - new AttributeDefinition("TYPE_NAME", "STRING_TYPE", - Multiplicity.REQUIRED, false, null) - } - ); + HierarchicalTypeDefinition<ClassType> databaseClassTypeDef = + new HierarchicalTypeDefinition<ClassType>("ClassType", DB_CLASS_TYPE, null, + new AttributeDefinition[]{ + new AttributeDefinition("DESC", "STRING_TYPE", Multiplicity.OPTIONAL, false, null), + new AttributeDefinition("DB_LOCATION_URI", "STRING_TYPE", Multiplicity.REQUIRED, + false, null), + new AttributeDefinition("NAME", "STRING_TYPE", Multiplicity.REQUIRED, false, null), + new AttributeDefinition("OWNER_TYPE", "STRING_TYPE", Multiplicity.OPTIONAL, false, + null), + new AttributeDefinition("OWNER_NAME", "STRING_TYPE", Multiplicity.OPTIONAL, false, + null)}); + + HierarchicalTypeDefinition<ClassType> tableClassTypeDef = + new HierarchicalTypeDefinition<ClassType>("ClassType", TB_CLASS_TYPE, null, + new AttributeDefinition[]{ + new AttributeDefinition("CREATE_TIME", "LONG_TYPE", Multiplicity.REQUIRED, false, + null), + new AttributeDefinition("LAST_ACCESS_TIME", "LONG_TYPE", Multiplicity.REQUIRED, + false, null), + new AttributeDefinition("OWNER", "STRING_TYPE", Multiplicity.REQUIRED, false, null), + new AttributeDefinition("TBL_NAME", "STRING_TYPE", Multiplicity.REQUIRED, false, + null), + new AttributeDefinition("TBL_TYPE", "STRING_TYPE", Multiplicity.REQUIRED, false, + null), + new AttributeDefinition("VIEW_EXPANDED_TEXT", "STRING_TYPE", Multiplicity.OPTIONAL, + false, null), + new AttributeDefinition("VIEW_ORIGINAL_TEXT", "STRING_TYPE", Multiplicity.OPTIONAL, + false, null)}); + + HierarchicalTypeDefinition<ClassType> columnClassTypeDef = + new HierarchicalTypeDefinition<ClassType>("ClassType", FD_CLASS_TYPE, null, + new AttributeDefinition[]{ + new AttributeDefinition("COMMENT", "STRING_TYPE", Multiplicity.OPTIONAL, false, + null), + new AttributeDefinition("COLUMN_NAME", "STRING_TYPE", Multiplicity.REQUIRED, false, + null), + new AttributeDefinition("TYPE_NAME", "STRING_TYPE", Multiplicity.REQUIRED, false, + null)}); } catch (ClassNotFoundException e) { e.printStackTrace(); @@ -108,8 +98,7 @@ public class HiveStructureBridge extends ABridge { try { ts.defineClassType(htd); } catch (MetadataException e) { - System.out.println( - htd.hierarchicalMetaTypeName + "could not be added to the type system"); + System.out.println(htd.hierarchicalMetaTypeName + "could not be added to the type system"); e.printStackTrace(); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/module/BridgeModule.java ---------------------------------------------------------------------- diff --git a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/module/BridgeModule.java b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/module/BridgeModule.java index 5f058ad..806f31e 100755 --- a/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/module/BridgeModule.java +++ b/addons/metadata-bridge-parent/metadata-bridge-core/src/main/java/org/apache/hadoop/metadata/bridge/module/BridgeModule.java @@ -33,8 +33,7 @@ import java.util.ArrayList; import java.util.List; public class BridgeModule extends AbstractModule { - public static final Logger LOG = LoggerFactory - .getLogger(BridgeModule.class); + public static final Logger LOG = LoggerFactory.getLogger(BridgeModule.class); @Override protected void configure() { @@ -44,11 +43,9 @@ public class BridgeModule extends AbstractModule { bind(BridgeTypeBootstrapper.class).in(Scopes.SINGLETON); // Load the configured bridge classes and add them to the map binder - MapBinder<Class, IBridge> mapbinder = MapBinder.newMapBinder(binder(), - Class.class, IBridge.class); + MapBinder<Class, IBridge> mapbinder = MapBinder.newMapBinder(binder(), Class.class, IBridge.class); - String propsURI = System.getProperty("bridgeManager.propsFile", - "bridge-manager.properties"); + String propsURI = System.getProperty("bridgeManager.propsFile", "bridge-manager.properties"); List<Class<? extends IBridge>> bridges = getBridgeClasses(propsURI); for (Class<? extends IBridge> bridgeClass : bridges) { @@ -59,8 +56,7 @@ public class BridgeModule extends AbstractModule { /* * Get the bridge classes from the configuration file */ - private List<Class<? extends IBridge>> getBridgeClasses( - String bridgePropFileName) { + private List<Class<? extends IBridge>> getBridgeClasses(String bridgePropFileName) { List<Class<? extends IBridge>> aBList = new ArrayList<Class<? extends IBridge>>(); PropertiesConfiguration config = new PropertiesConfiguration(); @@ -68,13 +64,11 @@ public class BridgeModule extends AbstractModule { try { LOG.info("Loading : Active Bridge List"); config.load(bridgePropFileName); - String[] activeBridgeList = ((String) config - .getProperty("BridgeManager.activeBridges")).split(","); + String[] activeBridgeList = ((String) config.getProperty("BridgeManager.activeBridges")).split(","); LOG.info("Loaded : Active Bridge List"); for (String s : activeBridgeList) { - Class<? extends IBridge> bridgeCls = (Class<? extends IBridge>) Class - .forName(s); + Class<? extends IBridge> bridgeCls = (Class<? extends IBridge>) Class.forName(s); aBList.add(bridgeCls); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/BridgeManagerTest.java ---------------------------------------------------------------------- diff --git a/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/BridgeManagerTest.java b/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/BridgeManagerTest.java index 50d6cb7..4045633 100755 --- a/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/BridgeManagerTest.java +++ b/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/BridgeManagerTest.java @@ -38,8 +38,7 @@ public class BridgeManagerTest { BridgeManager bm = new BridgeManager(repo); System.out.println(bm.getActiveBridges().size()); - Assert.assertEquals(bm.activeBridges.get(0).getClass().getSimpleName(), - "HiveLineageBridge"); + Assert.assertEquals(bm.activeBridges.get(0).getClass().getSimpleName(), "HiveLineageBridge"); } @Test http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/hivelineage/TestHiveLineageBridge.java ---------------------------------------------------------------------- diff --git a/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/hivelineage/TestHiveLineageBridge.java b/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/hivelineage/TestHiveLineageBridge.java index ba676f0..e72f13c 100755 --- a/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/hivelineage/TestHiveLineageBridge.java +++ b/addons/metadata-bridge-parent/metadata-bridge-core/src/test/java/org/apache/hadoop/metadata/bridge/hivelineage/TestHiveLineageBridge.java @@ -50,8 +50,7 @@ public class TestHiveLineageBridge { String oneId; private HiveLineage loadHiveLineageBean(String path) throws IOException { - return new Gson().fromJson(new InputStreamReader(this.getClass().getResourceAsStream(path)), - HiveLineage.class); + return new Gson().fromJson(new InputStreamReader(this.getClass().getResourceAsStream(path)), HiveLineage.class); } @BeforeClass http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/client/src/main/java/org/apache/atlas/AtlasClient.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/atlas/AtlasClient.java b/client/src/main/java/org/apache/atlas/AtlasClient.java index 2d5b360..3b9f5c3 100755 --- a/client/src/main/java/org/apache/atlas/AtlasClient.java +++ b/client/src/main/java/org/apache/atlas/AtlasClient.java @@ -86,7 +86,8 @@ public class AtlasClient { try { clientConfig = getClientProperties(); if (clientConfig.getBoolean(TLS_ENABLED, false)) { - // create an SSL properties configuration if one doesn't exist. SSLFactory expects a file, so forced to create a + // create an SSL properties configuration if one doesn't exist. SSLFactory expects a file, so forced + // to create a // configuration object, persist it, then subsequently pass in an empty configuration to SSLFactory SecureClientUtils.persistSSLClientConfiguration(clientConfig); } @@ -246,12 +247,12 @@ public class AtlasClient { * @return result json object * @throws AtlasServiceException */ - public JSONArray rawSearch(String typeName, String attributeName, Object attributeValue) throws - AtlasServiceException { -// String gremlinQuery = String.format( -// "g.V.has(\"typeName\",\"%s\").and(_().has(\"%s.%s\", T.eq, \"%s\")).toList()", -// typeName, typeName, attributeName, attributeValue); -// return searchByGremlin(gremlinQuery); + public JSONArray rawSearch(String typeName, String attributeName, Object attributeValue) + throws AtlasServiceException { + // String gremlinQuery = String.format( + // "g.V.has(\"typeName\",\"%s\").and(_().has(\"%s.%s\", T.eq, \"%s\")).toList()", + // typeName, typeName, attributeName, attributeValue); + // return searchByGremlin(gremlinQuery); String dslQuery = String.format("%s where %s = \"%s\"", typeName, attributeName, attributeValue); return searchByDSL(dslQuery); } @@ -340,14 +341,12 @@ public class AtlasClient { } private JSONObject callAPIWithResource(API api, WebResource resource, Object requestObject) - throws AtlasServiceException { - ClientResponse clientResponse = resource - .accept(JSON_MEDIA_TYPE) - .type(JSON_MEDIA_TYPE) + throws AtlasServiceException { + ClientResponse clientResponse = resource.accept(JSON_MEDIA_TYPE).type(JSON_MEDIA_TYPE) .method(api.getMethod(), ClientResponse.class, requestObject); - Response.Status expectedStatus = HttpMethod.POST.equals(api.getMethod()) - ? Response.Status.CREATED : Response.Status.OK; + Response.Status expectedStatus = + HttpMethod.POST.equals(api.getMethod()) ? Response.Status.CREATED : Response.Status.OK; if (clientResponse.getStatus() == expectedStatus.getStatusCode()) { String responseAsString = clientResponse.getEntity(String.class); try { @@ -360,8 +359,7 @@ public class AtlasClient { throw new AtlasServiceException(api, clientResponse); } - private JSONObject callAPI(API api, Object requestObject, - String... pathParams) throws AtlasServiceException { + private JSONObject callAPI(API api, Object requestObject, String... pathParams) throws AtlasServiceException { WebResource resource = getResource(api, pathParams); return callAPIWithResource(api, resource, requestObject); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java b/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java index beee09e..9d5641a 100644 --- a/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java +++ b/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java @@ -61,10 +61,8 @@ public class SecureClientUtils { public static URLConnectionClientHandler getClientConnectionHandler(DefaultClientConfig config, - PropertiesConfiguration clientConfig) { - config.getProperties().put( - URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND, - true); + PropertiesConfiguration clientConfig) { + config.getProperties().put(URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND, true); Configuration conf = new Configuration(false); conf.addResource(conf.get(SSLFactory.SSL_CLIENT_CONF_KEY, "ssl-client.xml")); String authType = "simple"; @@ -95,28 +93,25 @@ public class SecureClientUtils { return new URLConnectionClientHandler(httpURLConnectionFactory); } - private final static ConnectionConfigurator DEFAULT_TIMEOUT_CONN_CONFIGURATOR = - new ConnectionConfigurator() { - @Override - public HttpURLConnection configure(HttpURLConnection conn) - throws IOException { - setTimeouts(conn, DEFAULT_SOCKET_TIMEOUT); - return conn; - } - }; + private final static ConnectionConfigurator DEFAULT_TIMEOUT_CONN_CONFIGURATOR = new ConnectionConfigurator() { + @Override + public HttpURLConnection configure(HttpURLConnection conn) throws IOException { + setTimeouts(conn, DEFAULT_SOCKET_TIMEOUT); + return conn; + } + }; private static ConnectionConfigurator newConnConfigurator(Configuration conf) { try { return newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf); } catch (Exception e) { - LOG.debug("Cannot load customized ssl related configuration. " + - "Fallback to system-generic settings.", e); + LOG.debug("Cannot load customized ssl related configuration. " + "Fallback to system-generic settings.", e); return DEFAULT_TIMEOUT_CONN_CONFIGURATOR; } } - private static ConnectionConfigurator newSslConnConfigurator(final int timeout, - Configuration conf) throws IOException, GeneralSecurityException { + private static ConnectionConfigurator newSslConnConfigurator(final int timeout, Configuration conf) + throws IOException, GeneralSecurityException { final SSLFactory factory; final SSLSocketFactory sf; final HostnameVerifier hv; @@ -128,8 +123,7 @@ public class SecureClientUtils { return new ConnectionConfigurator() { @Override - public HttpURLConnection configure(HttpURLConnection conn) - throws IOException { + public HttpURLConnection configure(HttpURLConnection conn) throws IOException { if (conn instanceof HttpsURLConnection) { HttpsURLConnection c = (HttpsURLConnection) conn; c.setSSLSocketFactory(sf); @@ -168,7 +162,8 @@ public class SecureClientUtils { return new File(sslDir, SecurityProperties.SSL_CLIENT_PROPERTIES); } - public static void persistSSLClientConfiguration(PropertiesConfiguration clientConfig) throws AtlasException, IOException { + public static void persistSSLClientConfiguration(PropertiesConfiguration clientConfig) + throws AtlasException, IOException { //trust settings Configuration configuration = new Configuration(false); File sslClientFile = getSSLClientFile(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/client/src/test/java/org/apache/atlas/security/BaseSecurityTest.java ---------------------------------------------------------------------- diff --git a/client/src/test/java/org/apache/atlas/security/BaseSecurityTest.java b/client/src/test/java/org/apache/atlas/security/BaseSecurityTest.java index 13cce01..d1f43d1 100644 --- a/client/src/test/java/org/apache/atlas/security/BaseSecurityTest.java +++ b/client/src/test/java/org/apache/atlas/security/BaseSecurityTest.java @@ -36,18 +36,10 @@ import java.util.Properties; * */ public class BaseSecurityTest { - private static final String JAAS_ENTRY = - "%s { \n" - + " %s required\n" - // kerberos module - + " keyTab=\"%s\"\n" - + " debug=true\n" - + " principal=\"%s\"\n" - + " useKeyTab=true\n" - + " useTicketCache=false\n" - + " doNotPrompt=true\n" - + " storeKey=true;\n" - + "}; \n"; + private static final String JAAS_ENTRY = "%s { \n" + " %s required\n" + // kerberos module + + " keyTab=\"%s\"\n" + " debug=true\n" + " principal=\"%s\"\n" + " useKeyTab=true\n" + + " useTicketCache=false\n" + " doNotPrompt=true\n" + " storeKey=true;\n" + "}; \n"; protected MiniKdc kdc; protected String getWarPath() { @@ -56,8 +48,8 @@ public class BaseSecurityTest { } protected void generateTestProperties(Properties props) throws ConfigurationException, IOException { - PropertiesConfiguration config = new PropertiesConfiguration(System.getProperty("user.dir") + - "/../src/conf/application.properties"); + PropertiesConfiguration config = + new PropertiesConfiguration(System.getProperty("user.dir") + "/../src/conf/application.properties"); for (String propName : props.stringPropertyNames()) { config.setProperty(propName, props.getProperty(propName)); } @@ -88,20 +80,11 @@ public class BaseSecurityTest { return kdcWorkDir; } - public String createJAASEntry( - String context, - String principal, - File keytab) { + public String createJAASEntry(String context, String principal, File keytab) { String keytabpath = keytab.getAbsolutePath(); // fix up for windows; no-op on unix - keytabpath = keytabpath.replace('\\', '/'); - return String.format( - Locale.ENGLISH, - JAAS_ENTRY, - context, - getKerberosAuthModuleForJVM(), - keytabpath, - principal); + keytabpath = keytabpath.replace('\\', '/'); + return String.format(Locale.ENGLISH, JAAS_ENTRY, context, getKerberosAuthModuleForJVM(), keytabpath, principal); } protected String getKerberosAuthModuleForJVM() { @@ -119,10 +102,7 @@ public class BaseSecurityTest { protected File createKeytab(MiniKdc kdc, File kdcWorkDir, String principal, String filename) throws Exception { File keytab = new File(kdcWorkDir, filename); - kdc.createPrincipal(keytab, - principal, - principal + "/localhost", - principal + "/127.0.0.1"); + kdc.createPrincipal(keytab, principal, principal + "/localhost", principal + "/127.0.0.1"); return keytab; } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 76df53c..8bc921c 100755 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ <MaxPermGen>512m</MaxPermGen> <SnapshotsId>apache.snapshots.repo</SnapshotsId> <SnapshotsName>Apache Snapshot Repository</SnapshotsName> - <SnapshotsUrl> https://repository.apache.org/content/groups/snapshots</SnapshotsUrl> + <SnapshotsUrl>https://repository.apache.org/content/groups/snapshots</SnapshotsUrl> <StagingId>apache-staging</StagingId> <StagingName>Apache Release Distribution Repository</StagingName> <StagingUrl>https://repository.apache.org/content/groups/staging</StagingUrl> @@ -110,20 +110,28 @@ <profile> <id>Windows</id> <activation> - <os><family>windows</family></os> + <os> + <family>windows</family> + </os> </activation> <properties> - <python.path.l>${project.basedir}\src\bin;${project.basedir}\src\test\python\scripts;${project.basedir}\src\test\mock</python.path.l> + <python.path.l> + ${project.basedir}\src\bin;${project.basedir}\src\test\python\scripts;${project.basedir}\src\test\mock + </python.path.l> </properties> </profile> <profile> <id>Linux</id> <activation> - <os><family>!windows</family></os> + <os> + <family>!windows</family> + </os> </activation> <properties> - <python.path.l>${project.basedir}/src/bin:${project.basedir}/src/test/mock:${project.basedir}/src/test/python/scripts</python.path.l> + <python.path.l> + ${project.basedir}/src/bin:${project.basedir}/src/test/mock:${project.basedir}/src/test/python/scripts + </python.path.l> </properties> </profile> </profiles> @@ -192,18 +200,18 @@ <url>http://repo.typesafe.com/typesafe/releases/</url> </repository> </repositories> - <distributionManagement> - <repository> - <id>${StagingId}</id> - <name>${StagingName}</name> - <url>${StagingUrl}</url> - </repository> - <snapshotRepository> - <id>${SnapshotsId}</id> - <name>${SnapshotsName}</name> - <url>${SnapshotsUrl}</url> - </snapshotRepository> - </distributionManagement> + <distributionManagement> + <repository> + <id>${StagingId}</id> + <name>${StagingName}</name> + <url>${StagingUrl}</url> + </repository> + <snapshotRepository> + <id>${SnapshotsId}</id> + <name>${SnapshotsName}</name> + <url>${SnapshotsUrl}</url> + </snapshotRepository> + </distributionManagement> <dependencyManagement> <dependencies> <dependency> @@ -913,7 +921,8 @@ <redirectTestOutputToFile>true</redirectTestOutputToFile> <argLine>-Djava.awt.headless=true -Dproject.version=${project.version} -Dhadoop.tmp.dir=${project.build.directory}/tmp-hadoop-${user.name} - -Xmx1024m -XX:MaxPermSize=512m</argLine> + -Xmx1024m -XX:MaxPermSize=512m + </argLine> </configuration> <dependencies> <dependency> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/GraphTransaction.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/GraphTransaction.java b/repository/src/main/java/org/apache/atlas/GraphTransaction.java index 2c3983f..b73f4ed 100644 --- a/repository/src/main/java/org/apache/atlas/GraphTransaction.java +++ b/repository/src/main/java/org/apache/atlas/GraphTransaction.java @@ -22,5 +22,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) -public @interface GraphTransaction {} +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface GraphTransaction { +} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java b/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java index 0d9a4fe..3d47293 100644 --- a/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java +++ b/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java @@ -42,7 +42,7 @@ public class GraphTransactionInterceptor implements MethodInterceptor { titanGraph.commit(); LOG.debug("graph commit"); return response; - } catch (Throwable t){ + } catch (Throwable t) { titanGraph.rollback(); LOG.error("graph rollback due to exception ", t); throw t; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java b/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java index 8bbd0a7..e7353f9 100755 --- a/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java +++ b/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java @@ -18,8 +18,6 @@ package org.apache.atlas; -import com.google.inject.Provider; -import com.google.inject.TypeLiteral; import com.google.inject.matcher.Matchers; import com.google.inject.multibindings.Multibinder; import com.google.inject.throwingproviders.ThrowingProviderBinder; @@ -28,7 +26,6 @@ import org.aopalliance.intercept.MethodInterceptor; import org.apache.atlas.discovery.DiscoveryService; import org.apache.atlas.discovery.HiveLineageService; import org.apache.atlas.discovery.LineageService; -import org.apache.atlas.discovery.SearchIndexer; import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService; import org.apache.atlas.listener.TypesChangeListener; import org.apache.atlas.repository.MetadataRepository; @@ -49,9 +46,7 @@ public class RepositoryMetadataModule extends com.google.inject.AbstractModule { @Override protected void configure() { // special wiring for Titan Graph - ThrowingProviderBinder.create(binder()) - .bind(GraphProvider.class, TitanGraph.class) - .to(TitanGraphProvider.class) + ThrowingProviderBinder.create(binder()).bind(GraphProvider.class, TitanGraph.class).to(TitanGraphProvider.class) .asEagerSingleton(); // allow for dynamic binding of the metadata repo & graph service @@ -62,7 +57,8 @@ public class RepositoryMetadataModule extends com.google.inject.AbstractModule { // bind the ITypeStore interface to an implementation bind(ITypeStore.class).to(GraphBackedTypeStore.class).asEagerSingleton(); - Multibinder<TypesChangeListener> typesChangeListenerBinder = Multibinder.newSetBinder(binder(), TypesChangeListener.class); + Multibinder<TypesChangeListener> typesChangeListenerBinder = + Multibinder.newSetBinder(binder(), TypesChangeListener.class); typesChangeListenerBinder.addBinding().to(GraphBackedSearchIndexer.class); // bind the MetadataService interface to an implementation http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/discovery/HiveLineageService.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/HiveLineageService.java b/repository/src/main/java/org/apache/atlas/discovery/HiveLineageService.java index 2098ef0..9764f8f 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/HiveLineageService.java +++ b/repository/src/main/java/org/apache/atlas/discovery/HiveLineageService.java @@ -19,8 +19,8 @@ package org.apache.atlas.discovery; import com.thinkaurelius.titan.core.TitanGraph; -import org.apache.atlas.GraphTransaction; import org.apache.atlas.AtlasException; +import org.apache.atlas.GraphTransaction; import org.apache.atlas.ParamChecker; import org.apache.atlas.PropertiesUtil; import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy; @@ -65,20 +65,14 @@ public class HiveLineageService implements LineageService { // todo - externalize this using type system - dog food try { PropertiesConfiguration conf = PropertiesUtil.getApplicationProperties(); - HIVE_TABLE_TYPE_NAME = - conf.getString("atlas.lineage.hive.table.type.name", "DataSet"); - HIVE_PROCESS_TYPE_NAME = - conf.getString("atlas.lineage.hive.process.type.name", "Process"); - HIVE_PROCESS_INPUT_ATTRIBUTE_NAME = - conf.getString("atlas.lineage.hive.process.inputs.name", "inputs"); - HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME = - conf.getString("atlas.lineage.hive.process.outputs.name", "outputs"); - - HIVE_TABLE_SCHEMA_QUERY = conf.getString( - "atlas.lineage.hive.table.schema.query", - "hive_table where name=\"%s\", columns"); - HIVE_TABLE_EXISTS_QUERY = conf.getString( - "atlas.lineage.hive.table.exists.query", + HIVE_TABLE_TYPE_NAME = conf.getString("atlas.lineage.hive.table.type.name", "DataSet"); + HIVE_PROCESS_TYPE_NAME = conf.getString("atlas.lineage.hive.process.type.name", "Process"); + HIVE_PROCESS_INPUT_ATTRIBUTE_NAME = conf.getString("atlas.lineage.hive.process.inputs.name", "inputs"); + HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME = conf.getString("atlas.lineage.hive.process.outputs.name", "outputs"); + + HIVE_TABLE_SCHEMA_QUERY = + conf.getString("atlas.lineage.hive.table.schema.query", "hive_table where name=\"%s\", columns"); + HIVE_TABLE_EXISTS_QUERY = conf.getString("atlas.lineage.hive.table.exists.query", "from " + HIVE_TABLE_TYPE_NAME + " where name=\"%s\""); } catch (AtlasException e) { throw new RuntimeException(e); @@ -91,9 +85,8 @@ public class HiveLineageService implements LineageService { private final GraphBackedDiscoveryService discoveryService; @Inject - HiveLineageService(GraphProvider<TitanGraph> graphProvider, - MetadataRepository metadataRepository, - GraphBackedDiscoveryService discoveryService) throws DiscoveryException { + HiveLineageService(GraphProvider<TitanGraph> graphProvider, MetadataRepository metadataRepository, + GraphBackedDiscoveryService discoveryService) throws DiscoveryException { this.titanGraph = graphProvider.get(); this.graphPersistenceStrategy = new DefaultGraphPersistenceStrategy(metadataRepository); this.discoveryService = discoveryService; @@ -112,14 +105,13 @@ public class HiveLineageService implements LineageService { ParamChecker.notEmpty(tableName, "table name cannot be null"); validateTableExists(tableName); - HiveWhereUsedQuery outputsQuery = new HiveWhereUsedQuery( - HIVE_TABLE_TYPE_NAME, tableName, HIVE_PROCESS_TYPE_NAME, - HIVE_PROCESS_INPUT_ATTRIBUTE_NAME, HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME, - Option.empty(), SELECT_ATTRIBUTES, true, - graphPersistenceStrategy, titanGraph); + HiveWhereUsedQuery outputsQuery = + new HiveWhereUsedQuery(HIVE_TABLE_TYPE_NAME, tableName, HIVE_PROCESS_TYPE_NAME, + HIVE_PROCESS_INPUT_ATTRIBUTE_NAME, HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME, Option.empty(), + SELECT_ATTRIBUTES, true, graphPersistenceStrategy, titanGraph); Expressions.Expression expression = outputsQuery.expr(); - LOG.debug("Expression is [" + expression.toString() +"]"); + LOG.debug("Expression is [" + expression.toString() + "]"); try { return discoveryService.evaluate(expression).toJson(); } catch (Exception e) { // unable to catch ExpressionException @@ -140,11 +132,10 @@ public class HiveLineageService implements LineageService { ParamChecker.notEmpty(tableName, "table name cannot be null"); validateTableExists(tableName); - HiveWhereUsedQuery outputsQuery = new HiveWhereUsedQuery( - HIVE_TABLE_TYPE_NAME, tableName, HIVE_PROCESS_TYPE_NAME, - HIVE_PROCESS_INPUT_ATTRIBUTE_NAME, HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME, - Option.empty(), SELECT_ATTRIBUTES, true, - graphPersistenceStrategy, titanGraph); + HiveWhereUsedQuery outputsQuery = + new HiveWhereUsedQuery(HIVE_TABLE_TYPE_NAME, tableName, HIVE_PROCESS_TYPE_NAME, + HIVE_PROCESS_INPUT_ATTRIBUTE_NAME, HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME, Option.empty(), + SELECT_ATTRIBUTES, true, graphPersistenceStrategy, titanGraph); return outputsQuery.graph().toInstanceJson(); } @@ -161,14 +152,12 @@ public class HiveLineageService implements LineageService { ParamChecker.notEmpty(tableName, "table name cannot be null"); validateTableExists(tableName); - HiveLineageQuery inputsQuery = new HiveLineageQuery( - HIVE_TABLE_TYPE_NAME, tableName, HIVE_PROCESS_TYPE_NAME, - HIVE_PROCESS_INPUT_ATTRIBUTE_NAME, HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME, - Option.empty(), SELECT_ATTRIBUTES, true, - graphPersistenceStrategy, titanGraph); + HiveLineageQuery inputsQuery = new HiveLineageQuery(HIVE_TABLE_TYPE_NAME, tableName, HIVE_PROCESS_TYPE_NAME, + HIVE_PROCESS_INPUT_ATTRIBUTE_NAME, HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME, Option.empty(), + SELECT_ATTRIBUTES, true, graphPersistenceStrategy, titanGraph); Expressions.Expression expression = inputsQuery.expr(); - LOG.debug("Expression is [" + expression.toString() +"]"); + LOG.debug("Expression is [" + expression.toString() + "]"); try { return discoveryService.evaluate(expression).toJson(); } catch (Exception e) { // unable to catch ExpressionException @@ -189,11 +178,9 @@ public class HiveLineageService implements LineageService { ParamChecker.notEmpty(tableName, "table name cannot be null"); validateTableExists(tableName); - HiveLineageQuery inputsQuery = new HiveLineageQuery( - HIVE_TABLE_TYPE_NAME, tableName, HIVE_PROCESS_TYPE_NAME, - HIVE_PROCESS_INPUT_ATTRIBUTE_NAME, HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME, - Option.empty(), SELECT_ATTRIBUTES, true, - graphPersistenceStrategy, titanGraph); + HiveLineageQuery inputsQuery = new HiveLineageQuery(HIVE_TABLE_TYPE_NAME, tableName, HIVE_PROCESS_TYPE_NAME, + HIVE_PROCESS_INPUT_ATTRIBUTE_NAME, HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME, Option.empty(), + SELECT_ATTRIBUTES, true, graphPersistenceStrategy, titanGraph); return inputsQuery.graph().toInstanceJson(); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/discovery/SearchIndexer.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/SearchIndexer.java b/repository/src/main/java/org/apache/atlas/discovery/SearchIndexer.java index 37a9582..8e67e32 100755 --- a/repository/src/main/java/org/apache/atlas/discovery/SearchIndexer.java +++ b/repository/src/main/java/org/apache/atlas/discovery/SearchIndexer.java @@ -19,7 +19,6 @@ package org.apache.atlas.discovery; import org.apache.atlas.listener.TypesChangeListener; -import org.apache.atlas.repository.IndexException; /** http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/discovery/graph/DefaultGraphPersistenceStrategy.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/graph/DefaultGraphPersistenceStrategy.java b/repository/src/main/java/org/apache/atlas/discovery/graph/DefaultGraphPersistenceStrategy.java index 5b6b30b..c446d15 100755 --- a/repository/src/main/java/org/apache/atlas/discovery/graph/DefaultGraphPersistenceStrategy.java +++ b/repository/src/main/java/org/apache/atlas/discovery/graph/DefaultGraphPersistenceStrategy.java @@ -47,8 +47,7 @@ import java.util.List; */ public class DefaultGraphPersistenceStrategy implements GraphPersistenceStrategies { - private static final Logger LOG = LoggerFactory - .getLogger(DefaultGraphPersistenceStrategy.class); + private static final Logger LOG = LoggerFactory.getLogger(DefaultGraphPersistenceStrategy.class); private final GraphBackedMetadataRepository metadataRepository; @@ -104,60 +103,56 @@ public class DefaultGraphPersistenceStrategy implements GraphPersistenceStrategi public <U> U constructInstance(IDataType<U> dataType, Object value) { try { switch (dataType.getTypeCategory()) { - case PRIMITIVE: - case ENUM: - return dataType.convert(value, Multiplicity.OPTIONAL); - - case ARRAY: - // todo - break; - - case MAP: - // todo - break; - - case STRUCT: - TitanVertex structVertex = (TitanVertex) value; - StructType structType = (StructType) dataType; - ITypedStruct structInstance = structType.createInstance(); - - TypeSystem.IdType idType = TypeSystem.getInstance().getIdType(); - - if (dataType.getName().equals(idType.getName())) { - structInstance.set(idType.typeNameAttrName(), - structVertex.getProperty(typeAttributeName())); - structInstance.set(idType.idAttrName(), - structVertex.getProperty(idAttributeName())); - - } else { - metadataRepository.getGraphToInstanceMapper().mapVertexToInstance( - structVertex, structInstance, structType.fieldMapping().fields); - } - return dataType.convert(structInstance, Multiplicity.OPTIONAL); - - case TRAIT: - TitanVertex traitVertex = (TitanVertex) value; - TraitType traitType = (TraitType) dataType; - ITypedStruct traitInstance = traitType.createInstance(); - // todo - this is not right, we should load the Instance associated with this - // trait. for now just loading the trait struct. - // metadataRepository.getGraphToInstanceMapper().mapVertexToTraitInstance( - // traitVertex, dataType.getName(), , traitType, traitInstance); - metadataRepository.getGraphToInstanceMapper().mapVertexToInstance( - traitVertex, traitInstance, traitType.fieldMapping().fields); - break; - - case CLASS: - TitanVertex classVertex = (TitanVertex) value; - ITypedReferenceableInstance classInstance = - metadataRepository.getGraphToInstanceMapper().mapGraphToTypedInstance( - classVertex.<String>getProperty(Constants.GUID_PROPERTY_KEY), - classVertex); - return dataType.convert(classInstance, Multiplicity.OPTIONAL); - - default: - throw new UnsupportedOperationException( - "Load for type " + dataType + "is not supported"); + case PRIMITIVE: + case ENUM: + return dataType.convert(value, Multiplicity.OPTIONAL); + + case ARRAY: + // todo + break; + + case MAP: + // todo + break; + + case STRUCT: + TitanVertex structVertex = (TitanVertex) value; + StructType structType = (StructType) dataType; + ITypedStruct structInstance = structType.createInstance(); + + TypeSystem.IdType idType = TypeSystem.getInstance().getIdType(); + + if (dataType.getName().equals(idType.getName())) { + structInstance.set(idType.typeNameAttrName(), structVertex.getProperty(typeAttributeName())); + structInstance.set(idType.idAttrName(), structVertex.getProperty(idAttributeName())); + + } else { + metadataRepository.getGraphToInstanceMapper() + .mapVertexToInstance(structVertex, structInstance, structType.fieldMapping().fields); + } + return dataType.convert(structInstance, Multiplicity.OPTIONAL); + + case TRAIT: + TitanVertex traitVertex = (TitanVertex) value; + TraitType traitType = (TraitType) dataType; + ITypedStruct traitInstance = traitType.createInstance(); + // todo - this is not right, we should load the Instance associated with this + // trait. for now just loading the trait struct. + // metadataRepository.getGraphToInstanceMapper().mapVertexToTraitInstance( + // traitVertex, dataType.getName(), , traitType, traitInstance); + metadataRepository.getGraphToInstanceMapper() + .mapVertexToInstance(traitVertex, traitInstance, traitType.fieldMapping().fields); + break; + + case CLASS: + TitanVertex classVertex = (TitanVertex) value; + ITypedReferenceableInstance classInstance = metadataRepository.getGraphToInstanceMapper() + .mapGraphToTypedInstance(classVertex.<String>getProperty(Constants.GUID_PROPERTY_KEY), + classVertex); + return dataType.convert(classInstance, Multiplicity.OPTIONAL); + + default: + throw new UnsupportedOperationException("Load for type " + dataType + "is not supported"); } } catch (AtlasException e) { LOG.error("error while constructing an instance", e); @@ -168,9 +163,8 @@ public class DefaultGraphPersistenceStrategy implements GraphPersistenceStrategi @Override public String edgeLabel(TypeUtils.FieldInfo fInfo) { - return fInfo.reverseDataType() == null - ? edgeLabel(fInfo.dataType(), fInfo.attrInfo()) - : edgeLabel(fInfo.reverseDataType(), fInfo.attrInfo()); + return fInfo.reverseDataType() == null ? edgeLabel(fInfo.dataType(), fInfo.attrInfo()) : + edgeLabel(fInfo.reverseDataType(), fInfo.attrInfo()); } @Override @@ -184,13 +178,19 @@ public class DefaultGraphPersistenceStrategy implements GraphPersistenceStrategi } @Override - public String instanceToTraitEdgeDirection() { return "out"; } + public String instanceToTraitEdgeDirection() { + return "out"; + } @Override - public String traitToInstanceEdgeDirection() { return "in"; } + public String traitToInstanceEdgeDirection() { + return "in"; + } @Override - public String idAttributeName() { return metadataRepository.getIdAttributeName(); } + public String idAttributeName() { + return metadataRepository.getIdAttributeName(); + } @Override public scala.collection.Seq<String> typeTestExpression(String typeName, IntSequence intSeq) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java index 34ef7e6..5e84644 100755 --- a/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java +++ b/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java @@ -23,8 +23,8 @@ import com.thinkaurelius.titan.core.TitanIndexQuery; import com.thinkaurelius.titan.core.TitanProperty; import com.thinkaurelius.titan.core.TitanVertex; import com.tinkerpop.blueprints.Vertex; -import org.apache.atlas.GraphTransaction; import org.apache.atlas.AtlasClient; +import org.apache.atlas.GraphTransaction; import org.apache.atlas.discovery.DiscoveryException; import org.apache.atlas.discovery.DiscoveryService; import org.apache.atlas.query.Expressions; @@ -71,8 +71,8 @@ public class GraphBackedDiscoveryService implements DiscoveryService { public final static String SCORE = "score"; @Inject - GraphBackedDiscoveryService(GraphProvider<TitanGraph> graphProvider, - MetadataRepository metadataRepository) throws DiscoveryException { + GraphBackedDiscoveryService(GraphProvider<TitanGraph> graphProvider, MetadataRepository metadataRepository) + throws DiscoveryException { this.titanGraph = graphProvider.get(); this.graphPersistenceStrategy = new DefaultGraphPersistenceStrategy(metadataRepository); } @@ -86,7 +86,7 @@ public class GraphBackedDiscoveryService implements DiscoveryService { String graphQuery = String.format("v.%s:(%s)", Constants.ENTITY_TEXT_PROPERTY_KEY, query); LOG.debug("Full text query: {}", graphQuery); Iterator<TitanIndexQuery.Result<Vertex>> results = - titanGraph.indexQuery(Constants.FULLTEXT_INDEX, graphQuery).vertices().iterator(); + titanGraph.indexQuery(Constants.FULLTEXT_INDEX, graphQuery).vertices().iterator(); JSONArray response = new JSONArray(); while (results.hasNext()) { @@ -143,8 +143,7 @@ public class GraphBackedDiscoveryService implements DiscoveryService { public GremlinQueryResult evaluate(Expressions.Expression expression) { Expressions.Expression validatedExpression = QueryProcessor.validate(expression); - GremlinQuery gremlinQuery = - new GremlinTranslator(validatedExpression, graphPersistenceStrategy).translate(); + GremlinQuery gremlinQuery = new GremlinTranslator(validatedExpression, graphPersistenceStrategy).translate(); LOG.debug("Query = {}", validatedExpression); LOG.debug("Expression Tree = {}", validatedExpression.treeString()); LOG.debug("Gremlin Query = {}", gremlinQuery.queryStr()); @@ -162,8 +161,7 @@ public class GraphBackedDiscoveryService implements DiscoveryService { */ @Override @GraphTransaction - public List<Map<String, String>> searchByGremlin(String gremlinQuery) - throws DiscoveryException { + public List<Map<String, String>> searchByGremlin(String gremlinQuery) throws DiscoveryException { LOG.info("Executing gremlin query={}", gremlinQuery); ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("gremlin-groovy"); @@ -189,8 +187,7 @@ public class GraphBackedDiscoveryService implements DiscoveryService { Map<String, String> oRow = new HashMap<>(); if (r instanceof Map) { - @SuppressWarnings("unchecked") - Map<Object, Object> iRow = (Map) r; + @SuppressWarnings("unchecked") Map<Object, Object> iRow = (Map) r; for (Map.Entry e : iRow.entrySet()) { Object k = e.getKey(); Object v = e.getValue(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/repository/Constants.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/Constants.java b/repository/src/main/java/org/apache/atlas/repository/Constants.java index 9e3ec2d..fe43ad0 100755 --- a/repository/src/main/java/org/apache/atlas/repository/Constants.java +++ b/repository/src/main/java/org/apache/atlas/repository/Constants.java @@ -23,7 +23,7 @@ public final class Constants { /** * Globally Unique identifier property key. */ - + public static final String INTERNAL_PROPERTY_KEY_PREFIX = "__"; public static final String GUID_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "guid"; public static final String GUID_INDEX = "guid_index"; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/repository/EntityNotFoundException.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/EntityNotFoundException.java b/repository/src/main/java/org/apache/atlas/repository/EntityNotFoundException.java index 7c85d1e..db21bc7 100644 --- a/repository/src/main/java/org/apache/atlas/repository/EntityNotFoundException.java +++ b/repository/src/main/java/org/apache/atlas/repository/EntityNotFoundException.java @@ -38,7 +38,7 @@ public class EntityNotFoundException extends RepositoryException { } public EntityNotFoundException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { + boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/repository/IndexCreationException.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/IndexCreationException.java b/repository/src/main/java/org/apache/atlas/repository/IndexCreationException.java index 9f3e199..b7faf5a 100644 --- a/repository/src/main/java/org/apache/atlas/repository/IndexCreationException.java +++ b/repository/src/main/java/org/apache/atlas/repository/IndexCreationException.java @@ -35,7 +35,7 @@ public class IndexCreationException extends IndexException { } public IndexCreationException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { + boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/repository/IndexException.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/IndexException.java b/repository/src/main/java/org/apache/atlas/repository/IndexException.java index 485fb5f..60a6af1 100644 --- a/repository/src/main/java/org/apache/atlas/repository/IndexException.java +++ b/repository/src/main/java/org/apache/atlas/repository/IndexException.java @@ -37,8 +37,7 @@ public class IndexException extends AtlasException { super(cause); } - public IndexException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { + public IndexException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java b/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java index ebf54b5..1b0faa5 100755 --- a/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java +++ b/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java @@ -123,6 +123,7 @@ public interface MetadataRepository { // Trait management functions + /** * Gets the list of trait names for a given entity represented by a guid. * @@ -139,8 +140,7 @@ public interface MetadataRepository { * @param traitInstance trait instance that needs to be added to entity * @throws RepositoryException */ - void addTrait(String guid, - ITypedStruct traitInstance) throws RepositoryException; + void addTrait(String guid, ITypedStruct traitInstance) throws RepositoryException; /** * Deletes a given trait from an existing entity represented by a guid. @@ -149,8 +149,7 @@ public interface MetadataRepository { * @param traitNameToBeDeleted name of the trait * @throws RepositoryException */ - void deleteTrait(String guid, - String traitNameToBeDeleted) throws RepositoryException; + void deleteTrait(String guid, String traitNameToBeDeleted) throws RepositoryException; /** * Adds the property to the entity that corresponds to the GUID http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/main/java/org/apache/atlas/repository/RepositoryException.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/RepositoryException.java b/repository/src/main/java/org/apache/atlas/repository/RepositoryException.java index 8c08970..a934ecd 100755 --- a/repository/src/main/java/org/apache/atlas/repository/RepositoryException.java +++ b/repository/src/main/java/org/apache/atlas/repository/RepositoryException.java @@ -40,8 +40,7 @@ public class RepositoryException extends AtlasException { super(cause); } - public RepositoryException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { + public RepositoryException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } }
