http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java b/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java index c08fbc9..26dc6a8 100644 --- a/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java +++ b/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java @@ -21,10 +21,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.inject.Inject; import org.apache.atlas.CreateUpdateEntitiesResult; -import org.apache.atlas.TestOnlyModule; import org.apache.atlas.TestUtils; import org.apache.atlas.repository.MetadataRepository; -import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.typesystem.types.AttributeDefinition; @@ -40,7 +38,6 @@ import org.apache.atlas.typesystem.types.utils.TypesUtil; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Guice; import org.testng.annotations.Test; import java.util.Arrays; @@ -52,9 +49,7 @@ import java.util.Map; * Verifies automatic update of reverse references * */ -@Guice(modules = TestOnlyModule.class) public abstract class ReverseReferenceUpdateTestBase { - @Inject MetadataRepository repositoryService; @@ -63,8 +58,6 @@ public abstract class ReverseReferenceUpdateTestBase { protected ClassType typeA; protected ClassType typeB; - abstract DeleteHandler getDeleteHandler(TypeSystem typeSystem); - abstract void assertTestOneToOneReference(Object actual, ITypedReferenceableInstance expectedValue, ITypedReferenceableInstance referencingInstance) throws Exception; abstract void assertTestOneToManyReference(Object refValue, ITypedReferenceableInstance referencingInstance) throws Exception; @@ -73,8 +66,6 @@ public abstract class ReverseReferenceUpdateTestBase { typeSystem = TypeSystem.getInstance(); typeSystem.reset(); - new GraphBackedSearchIndexer(new AtlasTypeRegistry()); - HierarchicalTypeDefinition<ClassType> aDef = TypesUtil.createClassTypeDef("A", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), new AttributeDefinition("b", "B", Multiplicity.OPTIONAL, false, "a"), // 1-1 @@ -95,7 +86,6 @@ public abstract class ReverseReferenceUpdateTestBase { typeA = typeSystem.getDataType(ClassType.class, "A"); typeB = typeSystem.getDataType(ClassType.class, "B"); - repositoryService = new GraphBackedMetadataRepository(getDeleteHandler(typeSystem)); repositoryService = TestUtils.addTransactionWrapper(repositoryService); }
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java index b34db82..b835d22 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java @@ -18,8 +18,7 @@ package org.apache.atlas.repository.impexp; -import com.google.inject.Inject; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.impexp.AtlasExportRequest; @@ -33,20 +32,21 @@ import org.apache.atlas.repository.store.graph.v1.AtlasEntityChangeNotifier; import org.apache.atlas.repository.store.graph.v1.AtlasEntityStoreV1; import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1; +import org.apache.atlas.repository.store.graph.v1.EntityGraphMapper; import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; +import org.powermock.reflect.Whitebox; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; -import org.powermock.reflect.Whitebox; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeTest; import org.testng.annotations.Guice; import org.testng.annotations.Test; import scala.actors.threadpool.Arrays; +import javax.inject.Inject; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; @@ -61,7 +61,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class ExportServiceTest { private static final Logger LOG = LoggerFactory.getLogger(ExportServiceTest.class); @@ -71,6 +71,9 @@ public class ExportServiceTest { @Inject private AtlasTypeDefStore typeDefStore; + @Inject + private EntityGraphMapper graphMapper; + @Inject ExportService exportService; private DeleteHandlerV1 deleteHandler = mock(SoftDeleteHandlerV1.class);; private AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class); @@ -78,7 +81,7 @@ public class ExportServiceTest { @BeforeClass public void setupSampleData() throws AtlasBaseException { - entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier);; + entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper);; AtlasTypesDef sampleTypes = TestUtilsV2.defineDeptEmployeeTypes(); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(sampleTypes, typeRegistry); @@ -94,11 +97,6 @@ public class ExportServiceTest { LOG.debug("==> setupSampleData: ", AtlasEntity.dumpObjects(hrDept.getEntities(), null).toString()); } - @BeforeTest - public void setupExportService () throws AtlasBaseException { - exportService = new ExportService(typeRegistry); - } - @AfterClass public void clear() { AtlasGraphProvider.cleanup(); @@ -257,33 +255,33 @@ public class ExportServiceTest { @Test public void verifyOverallStatus() throws Exception { - ExportService service = new ExportService(typeRegistry); - assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(service, +// ExportService service = new ExportService(typeRegistry); + assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(exportService, "getOverallOperationStatus")); - assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.SUCCESS)); - assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.SUCCESS, AtlasExportResult.OperationStatus.SUCCESS, AtlasExportResult.OperationStatus.SUCCESS)); - assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, AtlasExportResult.OperationStatus.SUCCESS)); - assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.PARTIAL_SUCCESS)); - assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.FAIL, http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java index f9a0584..0aaaa70 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java @@ -18,7 +18,7 @@ package org.apache.atlas.repository.impexp; import com.google.inject.Inject; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; @@ -26,7 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Guice; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class ImportServiceReportingTest { private static final Logger LOG = LoggerFactory.getLogger(ImportServiceReportingTest.class); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java index 91966f8..08e9ee8 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java @@ -18,7 +18,7 @@ package org.apache.atlas.repository.impexp; import com.google.inject.Inject; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.store.AtlasTypeDefStore; @@ -36,7 +36,7 @@ import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getZip import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.loadModelFromJson; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.runAndVerifyQuickStart_v1_Import; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class ImportServiceTest { private static final Logger LOG = LoggerFactory.getLogger(ImportServiceTest.class); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java index 31fba33..5f01136 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java @@ -22,7 +22,7 @@ import com.google.inject.Inject; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasException; -import org.apache.atlas.RepositoryMetadataModule; +import org.apache.atlas.TestModules; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.typedef.AtlasEntityDef; import org.apache.atlas.repository.graph.AtlasGraphProvider; @@ -34,14 +34,10 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Guice; import org.testng.annotations.Test; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - /** * Tests for AtlasEntityStoreV1 */ -@Guice(modules = RepositoryMetadataModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class AtlasEntityDefStoreV1Test { @Inject http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java index 9b977db..9f7214c 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java @@ -18,7 +18,7 @@ package org.apache.atlas.repository.store.graph; import com.google.inject.Inject; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.SearchFilter; @@ -28,12 +28,10 @@ import org.apache.atlas.model.typedef.AtlasEnumDef; import org.apache.atlas.model.typedef.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; import org.apache.atlas.model.typedef.AtlasTypesDef; -import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.store.AtlasTypeDefStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; -import org.testng.annotations.AfterClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -44,7 +42,7 @@ import java.util.List; import static org.testng.Assert.*; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class AtlasTypeDefGraphStoreTest { private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefGraphStoreTest.class); @@ -52,11 +50,6 @@ public class AtlasTypeDefGraphStoreTest { private AtlasTypeDefStore typeDefStore; - @AfterClass - public void clear(){ - AtlasGraphProvider.cleanup(); - } - @Test(priority = 1) public void testGet() { try { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/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 index 9a11e08..9331e35 100644 --- 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 @@ -21,7 +21,6 @@ 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.TestOnlyModule; import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.exception.AtlasBaseException; @@ -39,7 +38,6 @@ 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.GraphBackedSearchIndexer; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasVertex; @@ -63,7 +61,6 @@ import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; -import org.testng.annotations.Guice; import org.testng.annotations.Test; import javax.inject.Inject; @@ -81,7 +78,6 @@ import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -@Guice(modules = TestOnlyModule.class) public abstract class AtlasDeleteHandlerV1Test { @Inject @@ -90,6 +86,7 @@ public abstract class AtlasDeleteHandlerV1Test { @Inject AtlasTypeDefStore typeDefStore; + @Inject AtlasEntityStore entityStore; @Inject @@ -101,13 +98,9 @@ public abstract class AtlasDeleteHandlerV1Test { private TypeSystem typeSystem = TypeSystem.getInstance(); - AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class); - - @BeforeClass public void setUp() throws Exception { metadataService = TestUtils.addSessionCleanupWrapper(metadataService); - new GraphBackedSearchIndexer(typeRegistry); final AtlasTypesDef deptTypesDef = TestUtilsV2.defineDeptEmployeeTypes(); typeDefStore.createTypesDef(deptTypesDef); @@ -144,8 +137,6 @@ public abstract class AtlasDeleteHandlerV1Test { @BeforeTest public void init() throws Exception { - DeleteHandlerV1 deleteHandler = getDeleteHandler(typeRegistry); - entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier); RequestContextV1.clear(); } @@ -155,8 +146,6 @@ public abstract class AtlasDeleteHandlerV1Test { AtlasGraphProvider.cleanup(); } - abstract DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry); - @Test public void testDeleteAndCreate() throws Exception { init(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java index 1dd7276..44067b9 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java @@ -20,8 +20,8 @@ package org.apache.atlas.repository.store.graph.v1; import com.google.common.collect.ImmutableSet; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasException; +import org.apache.atlas.TestModules; import org.apache.atlas.RequestContextV1; -import org.apache.atlas.TestOnlyModule; import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.exception.AtlasBaseException; @@ -83,7 +83,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class AtlasEntityStoreV1Test { private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityStoreV1Test.class); @@ -106,6 +106,8 @@ public class AtlasEntityStoreV1Test { private AtlasEntityWithExtInfo tblEntity; AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class); + @Inject + private EntityGraphMapper graphMapper; @BeforeClass @@ -137,7 +139,7 @@ public class AtlasEntityStoreV1Test { @BeforeTest public void init() throws Exception { - entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier); + entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper); RequestContextV1.clear(); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java index 4403b12..407ebff 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java @@ -20,6 +20,7 @@ package org.apache.atlas.repository.store.graph.v1; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasException; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtils; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity; @@ -28,11 +29,11 @@ import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graph.GraphHelper; 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.testng.Assert; +import org.testng.annotations.Guice; import java.util.List; import java.util.Map; @@ -44,13 +45,9 @@ import static org.testng.Assert.assertNull; import static org.testng.Assert.fail; import static org.testng.AssertJUnit.assertNotNull; +@Guice(modules = TestModules.HardDeleteModule.class) public class HardDeleteHandlerV1Test extends AtlasDeleteHandlerV1Test { - @Override - DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry) { - return new HardDeleteHandlerV1(typeRegistry); - } - @Override protected void assertTableForTestDeleteReference(String tableId) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java index 6a23807..d54adeb 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java @@ -18,10 +18,11 @@ package org.apache.atlas.repository.store.graph.v1; import com.google.common.collect.ImmutableList; +import org.apache.atlas.TestModules; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasObjectId; -import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeUtil; +import org.testng.annotations.Guice; import java.util.Map; @@ -31,15 +32,10 @@ import static org.testng.Assert.assertTrue; /** * Inverse reference update test with {@link HardDeleteHandlerV1} */ +@Guice(modules = TestModules.HardDeleteModule.class) public class InverseReferenceUpdateHardDeleteV1Test extends InverseReferenceUpdateV1Test { @Override - protected DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry) { - - return new HardDeleteHandlerV1(typeRegistry); - } - - @Override protected void verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception { // Max should have been removed from the subordinates list, leaving only John. http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java index ae6731c..884ab54 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java @@ -18,10 +18,11 @@ package org.apache.atlas.repository.store.graph.v1; import com.google.common.collect.ImmutableList; +import org.apache.atlas.TestModules; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasObjectId; -import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeUtil; +import org.testng.annotations.Guice; import java.util.Map; @@ -32,15 +33,10 @@ import static org.testng.Assert.assertTrue; /** * Inverse reference update test with {@link SoftDeleteHandlerV1} */ +@Guice(modules = TestModules.SoftDeleteModule.class) public class InverseReferenceUpdateSoftDeleteV1Test extends InverseReferenceUpdateV1Test { @Override - protected DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry) { - - return new SoftDeleteHandlerV1(typeRegistry); - } - - @Override protected void verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/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 c90f716..e2a8010 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.TestOnlyModule; import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.model.instance.AtlasEntity; @@ -31,7 +30,6 @@ import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.repository.graph.AtlasGraphProvider; -import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.services.MetadataService; @@ -42,7 +40,6 @@ import org.apache.atlas.type.AtlasTypeUtil; 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; @@ -52,7 +49,6 @@ import java.util.List; import java.util.Map; import static org.apache.atlas.TestUtils.NAME; -import static org.mockito.Mockito.mock; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; @@ -61,35 +57,26 @@ import static org.testng.Assert.assertTrue; * Test automatic inverse reference updating in V1 (V2?) code path. * */ -@Guice(modules = TestOnlyModule.class) public abstract class InverseReferenceUpdateV1Test { - @Inject AtlasTypeRegistry typeRegistry; @Inject AtlasTypeDefStore typeDefStore; + @Inject AtlasEntityStore entityStore; @Inject MetadataService metadataService; - @Inject - DeleteHandlerV1 deleteHandler; - private AtlasEntitiesWithExtInfo deptEntity; - AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class); - protected Map<String, AtlasObjectId> nameIdMap = new HashMap<>(); - protected abstract DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry); - @BeforeClass public void setUp() throws Exception { metadataService = TestUtils.addSessionCleanupWrapper(metadataService); - new GraphBackedSearchIndexer(typeRegistry); AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), TestUtilsV2.defineInverseReferenceTestTypes() @@ -104,8 +91,6 @@ public abstract class InverseReferenceUpdateV1Test { } deptEntity = TestUtilsV2.createDeptEg2(); - DeleteHandlerV1 deleteHandler = getDeleteHandler(typeRegistry); - entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier); init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(deptEntity), false); for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java index 8935faf..3f1ed03 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java @@ -19,6 +19,7 @@ package org.apache.atlas.repository.store.graph.v1; import org.apache.atlas.AtlasClient; +import org.apache.atlas.TestModules; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntityHeader; @@ -27,13 +28,13 @@ import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.services.MetadataService; -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.persistence.Id; import org.testng.Assert; +import org.testng.annotations.Guice; import javax.inject.Inject; import java.util.List; @@ -44,17 +45,13 @@ import static org.apache.atlas.TestUtils.NAME; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +@Guice(modules = TestModules.SoftDeleteModule.class) public class SoftDeleteHandlerV1Test extends AtlasDeleteHandlerV1Test { @Inject MetadataService metadataService; @Override - DeleteHandlerV1 getDeleteHandler(final AtlasTypeRegistry typeRegistry) { - return new SoftDeleteHandlerV1(typeRegistry); - } - - @Override protected void assertDeletedColumn(final AtlasEntity.AtlasEntityWithExtInfo tableInstance) throws AtlasBaseException { final List<AtlasObjectId> columns = (List<AtlasObjectId>) tableInstance.getEntity().getAttribute(COLUMNS_ATTR_NAME); Assert.assertEquals(columns.size(), 3); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java b/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java index 65cd938..6e3dabb 100755 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java @@ -21,10 +21,9 @@ package org.apache.atlas.repository.typestore; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.apache.atlas.AtlasException; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtils; import org.apache.atlas.repository.RepositoryException; -import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; @@ -50,7 +49,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAt import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef; import static org.apache.atlas.typesystem.types.utils.TypesUtil.createStructTypeDef; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class GraphBackedTypeStoreTest { private static final String DESCRIPTION = "_description"; @@ -70,7 +69,7 @@ public class GraphBackedTypeStoreTest { @AfterClass public void tearDown() throws Exception { ts.reset(); - AtlasGraphProvider.cleanup(); +// AtlasGraphProvider.cleanup(); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheConfigurationTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheConfigurationTest.java b/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheConfigurationTest.java deleted file mode 100644 index 6c5dcfc..0000000 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheConfigurationTest.java +++ /dev/null @@ -1,42 +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.typestore; - -import com.google.inject.Inject; -import org.apache.atlas.typesystem.types.cache.TypeCache; -import org.testng.Assert; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -/** - * Verify Guice can successfully instantiate and inject StoreBackTypeCache. - * StoreBackedTypeCacheTestModule Guice module uses Atlas configuration - * which has type cache implementation class set to {@link StoreBackedTypeCache}. - */ -@Guice(modules = StoreBackedTypeCacheTestOnlyModule.class) -public class StoreBackedTypeCacheConfigurationTest { - - @Inject - private TypeCache typeCache; - - @Test - public void testConfigureAsTypeCache() throws Exception { - // Verify Guice successfully instantiated and injected StoreBackTypeCache - Assert.assertTrue(typeCache instanceof StoreBackedTypeCache); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java b/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java index 1608bd7..2ea63ff 100644 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java @@ -20,9 +20,8 @@ package org.apache.atlas.repository.typestore; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.apache.atlas.AtlasException; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtils; -import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.typesystem.types.AttributeInfo; import org.apache.atlas.typesystem.types.ClassType; import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; @@ -46,7 +45,7 @@ import java.util.Map; /** * Unit test for {@link StoreBackedTypeCache} */ -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class StoreBackedTypeCacheTest { @Inject @@ -87,7 +86,7 @@ public class StoreBackedTypeCacheTest { @AfterClass public void tearDown() throws Exception { ts.reset(); - AtlasGraphProvider.cleanup(); +// AtlasGraphProvider.cleanup(); } @BeforeMethod http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTestOnlyModule.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTestOnlyModule.java b/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTestOnlyModule.java deleted file mode 100644 index 7fb0155..0000000 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTestOnlyModule.java +++ /dev/null @@ -1,44 +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.typestore; - -import org.apache.atlas.ApplicationProperties; -import org.apache.atlas.AtlasException; -import org.apache.atlas.TestOnlyModule; -import org.apache.atlas.util.AtlasRepositoryConfiguration; -import org.apache.commons.configuration.Configuration; - - -/** - * Guice module which sets TypeCache implementation class configuration property to {@link StoreBackedTypeCache}. - * - */ -public class StoreBackedTypeCacheTestOnlyModule extends TestOnlyModule { - - @Override - protected Configuration getConfiguration() { - try { - Configuration configuration = ApplicationProperties.get(); - configuration.setProperty(AtlasRepositoryConfiguration.TYPE_CACHE_IMPLEMENTATION_PROPERTY, - StoreBackedTypeCache.class.getName()); - return configuration; - } catch (AtlasException e) { - throw new RuntimeException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/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 index 7e2edd8..d8d8d91 100644 --- a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java @@ -24,14 +24,15 @@ import com.google.inject.Inject; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasException; import org.apache.atlas.EntityAuditEvent; +import org.apache.atlas.TestModules; import org.apache.atlas.RequestContext; -import org.apache.atlas.TestOnlyModule; 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.audit.EntityAuditRepository; import org.apache.atlas.repository.audit.HBaseBasedAuditRepository; @@ -85,7 +86,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeD import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef; import static org.testng.Assert.*; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class DefaultMetadataServiceTest { @Inject private MetadataService metadataService; @@ -150,7 +151,7 @@ public class DefaultMetadataServiceTest { AtlasGraphProvider.cleanup(); } } - private AtlasClient.EntityResult updateInstance(Referenceable entity) throws Exception { + private EntityResult updateInstance(Referenceable entity) throws Exception { RequestContext.createContext(); ParamChecker.notNull(entity, "Entity"); ParamChecker.notNull(entity.getId(), "Entity"); @@ -296,7 +297,7 @@ public class DefaultMetadataServiceTest { assertAuditEvents(id, EntityAuditEvent.EntityAuditAction.ENTITY_DELETE); } - private AtlasClient.EntityResult deleteEntities(String... guids) throws AtlasException { + private EntityResult deleteEntities(String... guids) throws AtlasException { RequestContext.createContext(); return metadataService.deleteEntities(Arrays.asList(guids)); } @@ -529,7 +530,7 @@ public class DefaultMetadataServiceTest { assertEquals(actualColumns, updatedColNameList); } - private AtlasClient.EntityResult updateEntityPartial(String guid, Referenceable entity) throws AtlasException { + private EntityResult updateEntityPartial(String guid, Referenceable entity) throws AtlasException { RequestContext.createContext(); return metadataService.updateEntityPartialByGuid(guid, entity).getEntityResult(); } @@ -547,7 +548,7 @@ public class DefaultMetadataServiceTest { put(COLUMNS_ATTR_NAME, columns); }}); - AtlasClient.EntityResult entityResult = updateEntityPartial(tableId._getId(), tableUpdated); + EntityResult entityResult = updateEntityPartial(tableId._getId(), tableUpdated); assertEquals(entityResult.getCreatedEntities().size(), 1); //col1 created assertEquals(entityResult.getUpdateEntities().size(), 1); //table updated assertEquals(entityResult.getUpdateEntities().get(0), tableId._getId()); @@ -1020,7 +1021,7 @@ public class DefaultMetadataServiceTest { //Delete one column String columnId = table1Columns.get(0).getId()._getId(); - AtlasClient.EntityResult entityResult = deleteEntities(columnId); + EntityResult entityResult = deleteEntities(columnId); //column is deleted and table is updated assertEquals(entityResult.getDeletedEntities().get(0), columnId); assertEquals(entityResult.getUpdateEntities().get(0), table1Entity.getId()._getId()); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java b/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java index 217fc8d..5c37b9e 100644 --- a/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java @@ -19,12 +19,11 @@ 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.TestModules; import org.apache.atlas.TestUtils; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.typestore.ITypeStore; import org.apache.atlas.repository.typestore.StoreBackedTypeCache; -import org.apache.atlas.repository.typestore.StoreBackedTypeCacheTestOnlyModule; import org.apache.atlas.services.MetadataService; import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.typesystem.json.TypesSerialization; @@ -44,14 +43,17 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Guice; import org.testng.annotations.Test; +import javax.inject.Inject; + /** * Verify MetadataService type operations trigger StoreBackedTypeCache to load non-cached types from the store. * StoreBackedTypeCacheTestModule Guice module sets Atlas configuration * to use {@link StoreBackedTypeCache} as the TypeCache implementation class. */ -@Guice(modules = StoreBackedTypeCacheTestOnlyModule.class) -public class StoreBackedTypeCacheMetadataServiceTest { +@Guice(modules = TestModules.StoreBackedTypeCacheTestModule.class) +public class StoreBackedTypeCacheMetadataServiceTest +{ @Inject private MetadataService metadataService; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java b/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java index d503ef7..d490083 100644 --- a/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java @@ -17,7 +17,7 @@ */ package org.apache.atlas.services; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules.TestOnlyModule; import org.apache.atlas.discovery.EntityDiscoveryService; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.typedef.AtlasEntityDef; @@ -28,7 +28,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Guice; import org.testng.annotations.Test; - import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.testng.Assert.assertEquals; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala ---------------------------------------------------------------------- diff --git a/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala b/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala index 60464be..a948d16 100755 --- a/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala +++ b/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala @@ -41,7 +41,7 @@ class GremlinTest extends BaseGremlinTest { @BeforeClass def beforeAll() { TypeSystem.getInstance().reset() - var repo = new GraphBackedMetadataRepository(null) + var repo = new GraphBackedMetadataRepository(null, new AtlasGraphProvider().get()) TestUtils.setupGraphProvider(repo) //force graph to be initialized first AtlasGraphProvider.getGraphInstance() http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala ---------------------------------------------------------------------- diff --git a/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala b/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala index cc22865..880a0c6 100755 --- a/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala +++ b/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala @@ -43,7 +43,7 @@ class GremlinTest2 extends BaseGremlinTest { def beforeAll() { TypeSystem.getInstance().reset() QueryTestsUtils.setupTypes - var repo = new GraphBackedMetadataRepository(null); + var repo = new GraphBackedMetadataRepository(null, null); gp = new DefaultGraphPersistenceStrategy(repo) g = QueryTestsUtils.setupTestGraph(repo) } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/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 index 3a3c967..b01cbf8 100755 --- a/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala +++ b/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala @@ -43,7 +43,7 @@ class LineageQueryTest extends BaseGremlinTest { @BeforeClass def beforeAll() { TypeSystem.getInstance().reset() - var repo = new GraphBackedMetadataRepository(null); + var repo = new GraphBackedMetadataRepository(null, new AtlasGraphProvider().get()); TestUtils.setupGraphProvider(repo); //force graph to be initialized first AtlasGraphProvider.getGraphInstance(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/server-api/pom.xml ---------------------------------------------------------------------- diff --git a/server-api/pom.xml b/server-api/pom.xml index 278184f..7761a71 100644 --- a/server-api/pom.xml +++ b/server-api/pom.xml @@ -37,11 +37,6 @@ </dependency> <dependency> - <groupId>com.google.inject</groupId> - <artifactId>guice</artifactId> - </dependency> - - <dependency> <groupId>org.apache.atlas</groupId> <artifactId>atlas-typesystem</artifactId> </dependency> @@ -60,58 +55,5 @@ <groupId>org.apache.atlas</groupId> <artifactId>atlas-client</artifactId> </dependency> - - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjrt</artifactId> - </dependency> </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>aspectj-maven-plugin</artifactId> - <configuration> - <complianceLevel>1.7</complianceLevel> - <showWeaveInfo>true</showWeaveInfo> - <verbose>true</verbose> - <forceAjcCompile>true</forceAjcCompile> - <includes> - <include>**/*.java</include> - <include>**/*.aj</include> - </includes> - </configuration> - <executions> - <execution> - <id>compile_with_aspectj</id> - <goals> - <goal>compile</goal> - </goals> - <configuration> - <aspectDirectory>src/main/java</aspectDirectory> - </configuration> - </execution> - <execution> - <id>test-compile_with_aspectj</id> - <goals> - <goal>test-compile</goal> - </goals> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjrt</artifactId> - <version>${aspectj.runtime.version}</version> - </dependency> - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjtools</artifactId> - <version>${aspectj.runtime.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> </project> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/server-api/src/main/java/org/apache/atlas/aspect/AtlasAspect.java ---------------------------------------------------------------------- diff --git a/server-api/src/main/java/org/apache/atlas/aspect/AtlasAspect.java b/server-api/src/main/java/org/apache/atlas/aspect/AtlasAspect.java deleted file mode 100644 index 3579dd2..0000000 --- a/server-api/src/main/java/org/apache/atlas/aspect/AtlasAspect.java +++ /dev/null @@ -1,68 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.aspect; - -import org.apache.atlas.RequestContext; -import org.apache.atlas.metrics.Metrics; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.Signature; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.List; - -@Aspect -public class AtlasAspect { - - public static final Logger LOG = LoggerFactory.getLogger(AtlasAspect.class); - - @Around("@annotation(org.apache.atlas.aspect.Monitored) && execution(* *(..))") - public Object collectMetricsForMonitored(ProceedingJoinPoint joinPoint) throws Throwable { - Signature methodSign = joinPoint.getSignature(); - Metrics metrics = RequestContext.getMetrics(); - String metricName = methodSign.getDeclaringType().getSimpleName() + "." + methodSign.getName(); - long start = System.currentTimeMillis(); - - try { - Object response = joinPoint.proceed(); - return response; - } finally { - metrics.record(metricName, (System.currentTimeMillis() - start)); - } - } - - @Around("@annotation(org.apache.atlas.aspect.Loggable) && execution(* *(..))") - public Object logAroundLoggable(ProceedingJoinPoint joinPoint) throws Throwable { - Signature methodSign = joinPoint.getSignature(); - String methodName = methodSign.getDeclaringType().getSimpleName() + "." + methodSign.getName(); - - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("==> %s(%s)", methodName, Arrays.toString(joinPoint.getArgs()))); - } - Object response = joinPoint.proceed(); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("<== %s(%s): %s", methodName, Arrays.toString(joinPoint.getArgs()), - response instanceof List ? ((List)response).size() : response)); - } - return response; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/server-api/src/main/java/org/apache/atlas/services/MetadataService.java ---------------------------------------------------------------------- diff --git a/server-api/src/main/java/org/apache/atlas/services/MetadataService.java b/server-api/src/main/java/org/apache/atlas/services/MetadataService.java index 31ef7b5..7fb3d3f 100644 --- a/server-api/src/main/java/org/apache/atlas/services/MetadataService.java +++ b/server-api/src/main/java/org/apache/atlas/services/MetadataService.java @@ -18,11 +18,11 @@ package org.apache.atlas.services; -import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasException; import org.apache.atlas.CreateUpdateEntitiesResult; import org.apache.atlas.EntityAuditEvent; import org.apache.atlas.listener.EntityChangeListener; +import org.apache.atlas.model.legacy.EntityResult; import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedStruct; @@ -267,7 +267,7 @@ public interface MetadataService { * @return List of guids for deleted entities * @throws AtlasException */ - AtlasClient.EntityResult deleteEntities(List<String> guids) throws AtlasException; + EntityResult deleteEntities(List<String> guids) throws AtlasException; /** * Register a listener for entity change. @@ -292,8 +292,8 @@ public interface MetadataService { * @return List of guids for deleted entities (including their composite references) * @throws AtlasException */ - AtlasClient.EntityResult deleteEntityByUniqueAttribute(String typeName, String uniqueAttributeName, - String attrValue) throws AtlasException; + EntityResult deleteEntityByUniqueAttribute(String typeName, String uniqueAttributeName, + String attrValue) throws AtlasException; /** * Returns entity audit events for entity id in the decreasing order of timestamp http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java index c853ec6..262f784 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java @@ -20,7 +20,6 @@ package org.apache.atlas.typesystem.types; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; - import org.apache.atlas.AtlasException; import org.apache.atlas.classification.InterfaceAudience; import org.apache.atlas.typesystem.TypesDef; @@ -31,6 +30,7 @@ import org.apache.atlas.typesystem.types.cache.TypeCache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.inject.Singleton; import java.lang.reflect.Constructor; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -41,8 +41,6 @@ import java.util.Set; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; -import javax.inject.Singleton; - @Singleton @InterfaceAudience.Private @Deprecated http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystemProvider.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystemProvider.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystemProvider.java deleted file mode 100644 index 4e1cd36..0000000 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystemProvider.java +++ /dev/null @@ -1,28 +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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.inject.Provider; - -public class TypeSystemProvider implements Provider<TypeSystem> { - @Override - public TypeSystem get() { - return TypeSystem.getInstance(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/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 index ce750af..0d86474 100644 --- 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 @@ -17,8 +17,8 @@ */ package org.apache.atlas.typesystem.types.cache; -import com.google.inject.Singleton; 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; @@ -29,7 +29,9 @@ 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; @@ -41,8 +43,10 @@ import java.util.concurrent.ConcurrentHashMap; /** * Caches the types in-memory within the same process space. */ -@Singleton @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); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/typesystem/src/main/resources/atlas-log4j.xml ---------------------------------------------------------------------- diff --git a/typesystem/src/main/resources/atlas-log4j.xml b/typesystem/src/main/resources/atlas-log4j.xml index 8312657..c30403e 100755 --- a/typesystem/src/main/resources/atlas-log4j.xml +++ b/typesystem/src/main/resources/atlas-log4j.xml @@ -75,6 +75,21 @@ <appender-ref ref="console"/> </logger> + <logger name="org.springframework" additivity="false"> + <level value="warn"/> + <appender-ref ref="console"/> + </logger> + + <logger name="org.eclipse" additivity="false"> + <level value="warn"/> + <appender-ref ref="console"/> + </logger> + + <logger name="com.sun.jersey" additivity="false"> + <level value="warn"/> + <appender-ref ref="console"/> + </logger> + <logger name="AUDIT" additivity="false"> <level value="info"/> <appender-ref ref="console"/> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/pom.xml ---------------------------------------------------------------------- diff --git a/webapp/pom.xml b/webapp/pom.xml index 045ccdb..4132912 100755 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@ -172,11 +172,6 @@ <artifactId>atlas-catalog</artifactId> </dependency> - <dependency> - <groupId>org.apache.atlas</groupId> - <artifactId>atlas-graphdb-impls</artifactId> - <type>pom</type> - </dependency> <!-- Zookeeper, curator --> <dependency> <groupId>org.apache.curator</groupId> @@ -276,18 +271,29 @@ </dependency> <dependency> + <groupId>com.google.inject</groupId> + <artifactId>guice</artifactId> + <version>${guice.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>com.google.inject.extensions</groupId> - <artifactId>guice-servlet</artifactId> + <artifactId>guice-throwingproviders</artifactId> + <version>${guice.version}</version> + <scope>test</scope> </dependency> <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> + <groupId>com.google.inject.extensions</groupId> + <artifactId>guice-multibindings</artifactId> + <version>${guice.version}</version> + <scope>test</scope> </dependency> <dependency> - <groupId>com.sun.jersey.contribs</groupId> - <artifactId>jersey-guice</artifactId> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> </dependency> <dependency> @@ -311,55 +317,94 @@ </dependency> <dependency> - <groupId>com.google.inject</groupId> - <artifactId>guice</artifactId> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - <version>${spring.version}</version> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-web</artifactId> - <version>${spring.version}</version> + <groupId>org.springframework</groupId> + <artifactId>spring-webmvc</artifactId> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-webmvc</artifactId> - <version>${spring.version}</version> + <groupId>org.springframework.security</groupId> + <artifactId>spring-security-core</artifactId> </dependency> <dependency> - <groupId>org.springframework.security</groupId> - <artifactId>spring-security-core</artifactId> - <version>${spring.security.version}</version> + <groupId>org.springframework.security</groupId> + <artifactId>spring-security-web</artifactId> </dependency> <dependency> - <groupId>org.springframework.security</groupId> - <artifactId>spring-security-web</artifactId> - <version>${spring.security.version}</version> + <groupId>org.springframework.security</groupId> + <artifactId>spring-security-config</artifactId> </dependency> <dependency> - <groupId>org.springframework.security</groupId> - <artifactId>spring-security-config</artifactId> - <version>${spring.security.version}</version> + <groupId>org.springframework.security</groupId> + <artifactId>spring-security-ldap</artifactId> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.ldap</groupId> + <artifactId>spring-ldap-core</artifactId> </dependency> + <!-- Jersey + Spring --> + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-spring</artifactId> + <version>1.8</version> + <exclusions> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring</artifactId> + </exclusion> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + </exclusion> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + </exclusion> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> - <groupId>org.springframework.security</groupId> - <artifactId>spring-security-ldap</artifactId> - <version>${spring.security.version}</version> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-servlet</artifactId> </dependency> + <!-- Required for Spring configuration processing --> <dependency> - <groupId>org.springframework.ldap</groupId> - <artifactId>spring-ldap-core</artifactId> - <version>${spring-ldap-core.version}</version> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjrt</artifactId> + <version>1.8.9</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjweaver</artifactId> + <version>1.8.9</version> </dependency> <dependency> <groupId>org.apache.atlas</groupId> @@ -367,11 +412,6 @@ <type>war</type> </dependency> <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>${javax.servlet.version}</version> - </dependency> - <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> <version>3.4</version> @@ -390,7 +430,8 @@ <classifier>tests</classifier> <scope>test</scope> </dependency> - <dependency> + + <dependency> <groupId>org.apache.atlas</groupId> <artifactId>atlas-repository</artifactId> <classifier>tests</classifier> @@ -414,10 +455,11 @@ </exclusion> </exclusions> </dependency> - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjrt</artifactId> + <groupId>org.apache.atlas</groupId> + <artifactId>atlas-repository</artifactId> + <classifier>tests</classifier> + <scope>test</scope> </dependency> <dependency> @@ -644,46 +686,6 @@ </plugin> <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>aspectj-maven-plugin</artifactId> - <configuration> - <complianceLevel>1.7</complianceLevel> - <includes> - <include>**/*.java</include> - <include>**/*.aj</include> - </includes> - <XaddSerialVersionUID>true</XaddSerialVersionUID> - <showWeaveInfo>true</showWeaveInfo> - <aspectLibraries> - <aspectLibrary> - <groupId>org.apache.atlas</groupId> - <artifactId>atlas-server-api</artifactId> - </aspectLibrary> - </aspectLibraries> - </configuration> - <executions> - <execution> - <id>compile_with_aspectj</id> - <goals> - <goal>compile</goal> - </goals> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjtools</artifactId> - <version>${aspectj.runtime.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.atlas</groupId> - <artifactId>atlas-server-api</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - <plugin> <groupId>com.webcohesion.enunciate</groupId> <artifactId>enunciate-maven-plugin</artifactId> <configuration> http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/Atlas.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/Atlas.java b/webapp/src/main/java/org/apache/atlas/Atlas.java index 14c43cc..e29254b 100755 --- a/webapp/src/main/java/org/apache/atlas/Atlas.java +++ b/webapp/src/main/java/org/apache/atlas/Atlas.java @@ -19,9 +19,7 @@ package org.apache.atlas; import org.apache.atlas.security.SecurityProperties; -import org.apache.atlas.setup.SetupException; import org.apache.atlas.web.service.EmbeddedServer; -import org.apache.atlas.web.setup.AtlasSetup; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.GnuParser; import org.apache.commons.cli.Option; @@ -33,6 +31,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.hadoop.util.ShutdownHookManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.bridge.SLF4JBridgeHandler; import java.util.Iterator; @@ -48,7 +47,7 @@ public final class Atlas { private static final String ATLAS_LOG_DIR = "atlas.log.dir"; public static final String ATLAS_SERVER_HTTPS_PORT = "atlas.server.https.port"; public static final String ATLAS_SERVER_HTTP_PORT = "atlas.server.http.port"; - public static final String ATLAS_SERVER_RUN_SETUP_KEY = "atlas.server.run.setup.on.start"; + private static EmbeddedServer server; @@ -111,28 +110,12 @@ public final class Atlas { final boolean enableTLS = isTLSEnabled(enableTLSFlag, appPort); configuration.setProperty(SecurityProperties.TLS_ENABLED, String.valueOf(enableTLS)); - runSetupIfRequired(configuration); showStartupInfo(buildConfiguration, enableTLS, appPort); server = EmbeddedServer.newServer(appPort, appPath, enableTLS); - server.start(); - } + installLogBridge(); - private static void runSetupIfRequired(Configuration configuration) throws SetupException { - boolean shouldRunSetup = configuration.getBoolean(ATLAS_SERVER_RUN_SETUP_KEY, false); - if (shouldRunSetup) { - LOG.warn("Running setup per configuration {}.", ATLAS_SERVER_RUN_SETUP_KEY); - AtlasSetup atlasSetup = new AtlasSetup(); - try { - atlasSetup.run(); - } catch (SetupException se) { - LOG.error("Failed running setup. Will not start the server."); - throw se; - } - LOG.warn("Finished running setup."); - } else { - LOG.info("Not running setup per configuration {}.", ATLAS_SERVER_RUN_SETUP_KEY); - } + server.start(); } private static void setApplicationHome() { @@ -204,4 +187,14 @@ public final class Atlas { LOG.info("Server starting with TLS ? {} on port {}", enableTLS, appPort); LOG.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); } + + private static void installLogBridge() { + // Optionally remove existing handlers attached to j.u.l root logger + SLF4JBridgeHandler.removeHandlersForRootLogger(); // (since SLF4J 1.6.5) + + // add SLF4JBridgeHandler to j.u.l's root logger, should be done once during + // the initialization phase of your application + SLF4JBridgeHandler.install(); + } + } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/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 f3af37d..6eadc96 100644 --- a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java +++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java @@ -18,7 +18,6 @@ package org.apache.atlas.notification; import com.google.common.annotations.VisibleForTesting; -import com.google.inject.Inject; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasException; import org.apache.atlas.listener.EntityChangeListener; @@ -35,7 +34,9 @@ import org.apache.atlas.typesystem.types.TypeSystem; 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; @@ -48,6 +49,7 @@ import java.util.Set; /** * Listen to the repository for entity changes and produce entity change notifications. */ +@Component public class NotificationEntityChangeListener implements EntityChangeListener { private final NotificationInterface notificationInterface; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java index e6d5697..2f8245d 100644 --- a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java +++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java @@ -19,7 +19,6 @@ package org.apache.atlas.notification; import com.google.common.annotations.VisibleForTesting; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.google.inject.Singleton; import kafka.consumer.ConsumerTimeoutException; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasException; @@ -45,6 +44,8 @@ import org.apache.atlas.web.util.DateTimeHelper; import org.apache.commons.configuration.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import javax.inject.Inject; import java.util.ArrayList; @@ -68,7 +69,8 @@ import static org.apache.atlas.notification.hook.HookNotification.HookNotificati /** * Consumer of notifications from hooks e.g., hive hook etc. */ -@Singleton +@Component +@Order(4) public class NotificationHookConsumer implements Service, ActiveStateChangeHandler { private static final Logger LOG = LoggerFactory.getLogger(NotificationHookConsumer.class); private static final String LOCALHOST = "localhost"; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java b/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java index 9042e88..98bd381 100644 --- a/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java +++ b/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java @@ -20,20 +20,19 @@ package org.apache.atlas.web.errors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; -import java.util.concurrent.ThreadLocalRandom; - -import javax.inject.Singleton; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; +import java.util.concurrent.ThreadLocalRandom; /** * Exception mapper for Jersey. * @param <E> */ @Provider -@Singleton +@Component public class AllExceptionMapper implements ExceptionMapper<Exception> { private static final Logger LOGGER = LoggerFactory.getLogger(AllExceptionMapper.class); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java b/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java index ec1767c..f4b8d67 100755 --- a/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java +++ b/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java @@ -21,8 +21,8 @@ package org.apache.atlas.web.errors; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.type.AtlasType; +import org.springframework.stereotype.Component; -import javax.inject.Singleton; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; @@ -34,7 +34,7 @@ import java.util.concurrent.ThreadLocalRandom; * AtlasBaseException mapper for Jersey. */ @Provider -@Singleton +@Component public class AtlasBaseExceptionMapper implements ExceptionMapper<AtlasBaseException> { @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java b/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java index 9f97bb2..a33d8d7 100644 --- a/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java +++ b/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java @@ -18,15 +18,15 @@ package org.apache.atlas.web.errors; import org.apache.atlas.typesystem.exception.NotFoundException; +import org.springframework.stereotype.Component; -import javax.inject.Singleton; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; import java.util.concurrent.ThreadLocalRandom; @Provider -@Singleton +@Component public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> { @Override public Response toResponse(NotFoundException e) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java index ecc67a7..36f2688 100644 --- a/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java +++ b/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java @@ -23,9 +23,9 @@ import org.apache.atlas.web.service.ServiceState; import org.apache.hadoop.http.HtmlQuoting; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; import javax.inject.Inject; -import javax.inject.Singleton; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -46,7 +46,7 @@ import java.io.IOException; * an error SERVICE_UNAVAILABLE. Identification of this state is carried out using * {@link ServiceState} and {@link ActiveInstanceState}. */ -@Singleton +@Component public class ActiveServerFilter implements Filter { private static final Logger LOG = LoggerFactory.getLogger(ActiveServerFilter.class);
