use of org.apache.atlas.model.impexp.AtlasExportResult in project incubator-atlas by apache.
the class ExportServiceTest method requestingEntityNotFound_NoData.
@Test
public void requestingEntityNotFound_NoData() throws AtlasBaseException, IOException {
String requestingIP = "1.0.0.0";
String hostName = "root";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipSink zipSink = new ZipSink(baos);
AtlasExportResult result = exportService.run(zipSink, getRequestForFullFetch(), "admin", hostName, requestingIP);
Assert.assertNull(result.getData());
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ZipSource zipSource = new ZipSource(bais);
assertNotNull(exportService);
assertNotNull(zipSource.getCreationOrder());
Assert.assertFalse(zipSource.hasNext());
}
use of org.apache.atlas.model.impexp.AtlasExportResult in project incubator-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;
}
use of org.apache.atlas.model.impexp.AtlasExportResult in project incubator-atlas by apache.
the class ImportServiceTestUtils 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();
AtlasImportRequest request = getDefaultImportRequest();
AtlasImportResult result = runImportWithParameters(importService, request, zipSource);
Assert.assertNotNull(result);
verifyImportedMetrics(exportResult, result);
verifyImportedEntities(creationOrder, result.getProcessedEntities());
}
use of org.apache.atlas.model.impexp.AtlasExportResult in project incubator-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;
}
use of org.apache.atlas.model.impexp.AtlasExportResult in project incubator-atlas by apache.
the class AdminResource method export.
@POST
@Path("/export")
@Consumes(Servlets.JSON_MEDIA_TYPE)
public Response export(AtlasExportRequest request) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AdminResource.export()");
}
acquireExportImportLock("export");
ZipSink exportSink = null;
try {
exportSink = new ZipSink(httpServletResponse.getOutputStream());
AtlasExportResult result = exportService.run(exportSink, request, Servlets.getUserName(httpServletRequest), Servlets.getHostName(httpServletRequest), AtlasAuthorizationUtils.getRequestIpAddress(httpServletRequest));
exportSink.close();
httpServletResponse.addHeader("Content-Encoding", "gzip");
httpServletResponse.setContentType("application/zip");
httpServletResponse.setHeader("Content-Disposition", "attachment; filename=" + result.getClass().getSimpleName());
httpServletResponse.setHeader("Transfer-Encoding", "chunked");
httpServletResponse.getOutputStream().flush();
return Response.ok().build();
} catch (IOException excp) {
LOG.error("export() failed", excp);
throw new AtlasBaseException(excp);
} finally {
releaseExportImportLock();
if (exportSink != null) {
exportSink.close();
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AdminResource.export()");
}
}
}
Aggregations