Search in sources :

Example 1 with AtlasExportResult

use of org.apache.atlas.model.impexp.AtlasExportResult in project atlas by apache.

the class ZipFileResourceTestUtils method runAndVerifyQuickStart_v1_Import.

public static void runAndVerifyQuickStart_v1_Import(ImportService importService, ZipSource zipSource) throws AtlasBaseException, IOException {
    AtlasExportResult exportResult = zipSource.getExportResult();
    List<String> creationOrder = zipSource.getCreationOrder();
    RequestContextV1.clear();
    RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null);
    AtlasImportRequest request = getDefaultImportRequest();
    AtlasImportResult result = runImportWithParameters(importService, request, zipSource);
    assertNotNull(result);
    verifyImportedMetrics(exportResult, result);
    verifyImportedEntities(creationOrder, result.getProcessedEntities());
}
Also used : AtlasExportResult(org.apache.atlas.model.impexp.AtlasExportResult) AtlasImportResult(org.apache.atlas.model.impexp.AtlasImportResult) AtlasImportRequest(org.apache.atlas.model.impexp.AtlasImportRequest)

Example 2 with AtlasExportResult

use of org.apache.atlas.model.impexp.AtlasExportResult in project atlas by apache.

the class ExportServiceTest method exportType_Succeeds.

@Test
public void exportType_Succeeds() throws AtlasBaseException, FileNotFoundException {
    String requestingIP = "1.0.0.0";
    String hostName = "root";
    AtlasExportRequest request = getRequestForFullFetch();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipSink zipSink = new ZipSink(baos);
    AtlasExportResult result = exportService.run(zipSink, request, "admin", hostName, requestingIP);
    assertNotNull(exportService);
    assertEquals(result.getHostName(), hostName);
    assertEquals(result.getClientIpAddress(), requestingIP);
    assertEquals(request, result.getRequest());
}
Also used : AtlasExportResult(org.apache.atlas.model.impexp.AtlasExportResult) AtlasExportRequest(org.apache.atlas.model.impexp.AtlasExportRequest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with AtlasExportResult

use of org.apache.atlas.model.impexp.AtlasExportResult in project atlas by apache.

the class ExportServiceTest method runExportWithParameters.

private ZipSource runExportWithParameters(AtlasExportRequest request) throws AtlasBaseException, IOException {
    final String requestingIP = "1.0.0.0";
    final String hostName = "localhost";
    final String userName = "admin";
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipSink zipSink = new ZipSink(baos);
    AtlasExportResult result = exportService.run(zipSink, request, userName, hostName, requestingIP);
    zipSink.close();
    ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
    ZipSource zipSource = new ZipSource(bis);
    return zipSource;
}
Also used : AtlasExportResult(org.apache.atlas.model.impexp.AtlasExportResult) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 4 with AtlasExportResult

use of org.apache.atlas.model.impexp.AtlasExportResult in project atlas by apache.

the class ExportService method run.

public AtlasExportResult run(ZipSink exportSink, AtlasExportRequest request, String userName, String hostName, String requestingIP) throws AtlasBaseException {
    long startTime = System.currentTimeMillis();
    AtlasExportResult result = new AtlasExportResult(request, userName, requestingIP, hostName, startTime);
    ExportContext context = new ExportContext(result, exportSink);
    try {
        LOG.info("==> export(user={}, from={})", userName, requestingIP);
        AtlasExportResult.OperationStatus[] statuses = processItems(request, context);
        processTypesDef(context);
        updateSinkWithOperationMetrics(context, statuses, getOperationDuration(startTime));
    } catch (Exception ex) {
        LOG.error("Operation failed: ", ex);
    } finally {
        atlasGraph.releaseGremlinScriptEngine(context.scriptEngine);
        LOG.info("<== export(user={}, from={}): status {}", userName, requestingIP, context.result.getOperationStatus());
        context.clear();
        result.clear();
    }
    return context.result;
}
Also used : AtlasExportResult(org.apache.atlas.model.impexp.AtlasExportResult) ScriptException(javax.script.ScriptException) AtlasServiceException(org.apache.atlas.AtlasServiceException) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasException(org.apache.atlas.AtlasException)

Example 5 with AtlasExportResult

use of org.apache.atlas.model.impexp.AtlasExportResult in project incubator-atlas by apache.

the class ZipFileResourceTestUtils method runAndVerifyQuickStart_v1_Import.

public static void runAndVerifyQuickStart_v1_Import(ImportService importService, ZipSource zipSource) throws AtlasBaseException, IOException {
    AtlasExportResult exportResult = zipSource.getExportResult();
    List<String> creationOrder = zipSource.getCreationOrder();
    RequestContextV1.clear();
    AtlasImportRequest request = getDefaultImportRequest();
    AtlasImportResult result = runImportWithParameters(importService, request, zipSource);
    assertNotNull(result);
    verifyImportedMetrics(exportResult, result);
    verifyImportedEntities(creationOrder, result.getProcessedEntities());
}
Also used : AtlasExportResult(org.apache.atlas.model.impexp.AtlasExportResult) AtlasImportResult(org.apache.atlas.model.impexp.AtlasImportResult) AtlasImportRequest(org.apache.atlas.model.impexp.AtlasImportRequest)

Aggregations

AtlasExportResult (org.apache.atlas.model.impexp.AtlasExportResult)15 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)4 AtlasExportRequest (org.apache.atlas.model.impexp.AtlasExportRequest)4 Test (org.testng.annotations.Test)4 AtlasImportRequest (org.apache.atlas.model.impexp.AtlasImportRequest)3 AtlasImportResult (org.apache.atlas.model.impexp.AtlasImportResult)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ScriptException (javax.script.ScriptException)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 AtlasException (org.apache.atlas.AtlasException)2 AtlasServiceException (org.apache.atlas.AtlasServiceException)2 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)2 ZipSink (org.apache.atlas.repository.impexp.ZipSink)2 BeforeTest (org.testng.annotations.BeforeTest)2 AtlasAdminAccessRequest (org.apache.atlas.authorize.AtlasAdminAccessRequest)1