Commit 116fb62c by Ashutosh Mestry

ATLAS-2845: Rename AtlasCluster to AtlasServer.

parent c0a91c7e
......@@ -100,12 +100,20 @@
]
},
{
"name": "AtlasCluster",
"name": "AtlasServer",
"typeVersion": "1.0",
"superTypes": [
],
"attributeDefs": [
{
"name": "name",
"typeName": "string",
"cardinality": "SINGLE",
"isIndexable": true,
"isOptional": false,
"isUnique": false
},
{
"name": "displayName",
"typeName": "string",
"cardinality": "SINGLE",
......@@ -114,7 +122,7 @@
"isUnique": false
},
{
"name": "qualifiedName",
"name": "fullName",
"typeName": "string",
"cardinality": "SINGLE",
"isIndexable": true,
......@@ -258,7 +266,7 @@
"isUnique": false
},
{
"name": "sourceClusterName",
"name": "sourceServerName",
"typeName": "string",
"cardinality": "SINGLE",
"isIndexable": true,
......@@ -266,7 +274,7 @@
"isUnique": false
},
{
"name": "targetClusterName",
"name": "targetServerName",
"typeName": "string",
"cardinality": "SINGLE",
"isIndexable": true,
......
......@@ -8,16 +8,16 @@
"params": null,
"attributeDefs": [
{
"name": "replicatedFromCluster",
"typeName": "array<AtlasCluster>",
"name": "replicatedFrom",
"typeName": "array<AtlasServer>",
"cardinality": "SET",
"isIndexable": false,
"isOptional": true,
"isUnique": false
},
{
"name": "replicatedToCluster",
"typeName": "array<AtlasCluster>",
"name": "replicatedTo",
"typeName": "array<AtlasServer>",
"cardinality": "SET",
"isIndexable": false,
"isOptional": true,
......
......@@ -37,7 +37,7 @@ import com.sun.jersey.multipart.MultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart;
import com.sun.jersey.multipart.file.StreamDataBodyPart;
import com.sun.jersey.multipart.impl.MultiPartWriter;
import org.apache.atlas.model.impexp.AtlasCluster;
import org.apache.atlas.model.impexp.AtlasServer;
import org.apache.atlas.model.impexp.AtlasExportRequest;
import org.apache.atlas.model.impexp.AtlasImportRequest;
import org.apache.atlas.model.impexp.AtlasImportResult;
......@@ -80,7 +80,7 @@ public abstract class AtlasBaseClient {
public static final String ADMIN_METRICS = "admin/metrics";
public static final String ADMIN_IMPORT = "admin/import";
public static final String ADMIN_EXPORT = "admin/export";
public static final String ADMIN_CLUSTER_TEMPLATE = "%sadmin/cluster/%s";
public static final String ADMIN_SERVER_TEMPLATE = "%sadmin/server/%s";
public static final String QUERY = "query";
public static final String LIMIT = "limit";
......@@ -526,9 +526,9 @@ public abstract class AtlasBaseClient {
return new FormDataBodyPart(IMPORT_REQUEST_PARAMTER, AtlasType.toJson(request), MediaType.APPLICATION_JSON_TYPE);
}
public AtlasCluster getCluster(String clusterName) throws AtlasServiceException {
API api = new API(String.format(ADMIN_CLUSTER_TEMPLATE, BASE_URI, clusterName), HttpMethod.GET, Response.Status.OK);
return callAPI(api, AtlasCluster.class, null);
public AtlasServer getServer(String serverName) throws AtlasServiceException {
API api = new API(String.format(ADMIN_SERVER_TEMPLATE, BASE_URI, serverName), HttpMethod.GET, Response.Status.OK);
return callAPI(api, AtlasServer.class, null);
}
boolean isRetryableException(ClientHandlerException che) {
......
......@@ -164,8 +164,8 @@ public final class Constants {
*/
public static final String ATTR_NAME_REFERENCEABLE = "Referenceable.";
public static final String ATTR_NAME_REPLICATED_TO_CLUSTER = "replicatedToCluster";
public static final String ATTR_NAME_REPLICATED_FROM_CLUSTER = "replicatedFromCluster";
public static final String ATTR_NAME_REPLICATED_TO = "replicatedTo";
public static final String ATTR_NAME_REPLICATED_FROM = "replicatedFrom";
private Constants() {
}
......
......@@ -35,25 +35,28 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AtlasCluster extends AtlasBaseModelObject implements Serializable {
public class AtlasServer extends AtlasBaseModelObject implements Serializable {
private static final long serialVersionUID = 1L;
public static final String KEY_REPLICATION_DETAILS = "REPL_DETAILS";
private String name;
private String qualifiedName;
private Map<String, String> additionalInfo;
private List<String> urls;
private String name;
private String fullName;
private String displayName;
private Map<String, String> additionalInfo = new HashMap<>();
private List<String> urls = new ArrayList<>();
public AtlasCluster() {
urls = new ArrayList<>();
additionalInfo = new HashMap<>();
public AtlasServer() {
}
public AtlasCluster(String name, String qualifiedName) {
this();
this.name = name;
this.qualifiedName = qualifiedName;
public AtlasServer(String name, String fullName) {
this(name, name, fullName);
}
public AtlasServer(String name, String displayName, String fullName) {
this.name = name;
this.displayName = displayName;
this.fullName = fullName;
}
public void setName(String name) {
......@@ -64,12 +67,45 @@ public class AtlasCluster extends AtlasBaseModelObject implements Serializable {
return this.name;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public void setAdditionalInfo(Map<String, String> additionalInfo) {
this.additionalInfo = additionalInfo;
}
public Map<String, String> getAdditionalInfo() {
return this.additionalInfo;
}
public String getAdditionalInfo(String key) {
return additionalInfo.get(key);
}
public void setUrls(List<String> urls) {
this.urls = urls;
}
public List<String> getUrls() {
return this.urls;
}
public void setAdditionalInfo(String key, String value) {
if(additionalInfo == null) {
if (additionalInfo == null) {
additionalInfo = new HashMap<>();
}
......@@ -79,15 +115,15 @@ public class AtlasCluster extends AtlasBaseModelObject implements Serializable {
public void setAdditionalInfoRepl(String guid, long modifiedTimestamp) {
Map<String, Object> replicationDetailsMap = null;
if(additionalInfo != null && additionalInfo.containsKey(KEY_REPLICATION_DETAILS)) {
if (additionalInfo != null && additionalInfo.containsKey(KEY_REPLICATION_DETAILS)) {
replicationDetailsMap = AtlasType.fromJson(getAdditionalInfo().get(KEY_REPLICATION_DETAILS), Map.class);
}
if(replicationDetailsMap == null) {
if (replicationDetailsMap == null) {
replicationDetailsMap = new HashMap<>();
}
if(modifiedTimestamp == 0) {
if (modifiedTimestamp == 0) {
replicationDetailsMap.remove(guid);
} else {
replicationDetailsMap.put(guid, modifiedTimestamp);
......@@ -96,59 +132,37 @@ public class AtlasCluster extends AtlasBaseModelObject implements Serializable {
updateReplicationMap(replicationDetailsMap);
}
private void updateReplicationMap(Map<String, Object> replicationDetailsMap) {
String json = AtlasType.toJson(replicationDetailsMap);
setAdditionalInfo(KEY_REPLICATION_DETAILS, json);
}
public Object getAdditionalInfoRepl(String guid) {
if(additionalInfo == null || !additionalInfo.containsKey(KEY_REPLICATION_DETAILS)) {
if (additionalInfo == null || !additionalInfo.containsKey(KEY_REPLICATION_DETAILS)) {
return null;
}
String key = guid;
String key = guid;
String mapJson = additionalInfo.get(KEY_REPLICATION_DETAILS);
Map<String, String> replicationDetailsMap = AtlasType.fromJson(mapJson, Map.class);
if(!replicationDetailsMap.containsKey(key)) {
if (!replicationDetailsMap.containsKey(key)) {
return null;
}
return replicationDetailsMap.get(key);
}
public Map<String, String> getAdditionalInfo() {
return this.additionalInfo;
}
public String getAdditionalInfo(String key) {
return additionalInfo.get(key);
}
public String getQualifiedName() {
return qualifiedName;
}
public void setQualifiedName(String qualifiedName) {
this.qualifiedName = qualifiedName;
}
public void setUrls(List<String> urls) {
this.urls = urls;
}
public List<String> getUrls() {
return this.urls;
}
@Override
public StringBuilder toString(StringBuilder sb) {
sb.append(", name=").append(name);
sb.append(", qualifiedName=").append(getQualifiedName());
sb.append(", urls=").append(urls);
sb.append(", fullName=").append(fullName);
sb.append(", displayName=").append(displayName);
sb.append(", additionalInfo=").append(additionalInfo);
sb.append("}");
sb.append(", urls=").append(urls);
return sb;
}
private void updateReplicationMap(Map<String, Object> replicationDetailsMap) {
String json = AtlasType.toJson(replicationDetailsMap);
setAdditionalInfo(KEY_REPLICATION_DETAILS, json);
}
}
......@@ -93,19 +93,19 @@ public class ExportImportAuditEntry extends AtlasBaseModelObject implements Seri
return this.endTime;
}
public String getTargetClusterName() {
public String getTargetServerName() {
return this.targetClusterName;
}
public String getSourceClusterName() {
public String getSourceServerName() {
return this.sourceClusterName;
}
public void setSourceClusterName(String sourceClusterName) {
public void setSourceServerName(String sourceClusterName) {
this.sourceClusterName = sourceClusterName;
}
public void setTargetClusterName(String targetClusterName) {
public void setTargetServerName(String targetClusterName) {
this.targetClusterName = targetClusterName;
}
......
......@@ -21,7 +21,7 @@ package org.apache.atlas.repository.impexp;
import org.apache.atlas.annotation.AtlasService;
import org.apache.atlas.annotation.GraphTransaction;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasCluster;
import org.apache.atlas.model.impexp.AtlasServer;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.repository.graphdb.AtlasVertex;
......@@ -42,8 +42,8 @@ import java.util.ArrayList;
import java.util.List;
@AtlasService
public class ClusterService {
private static final Logger LOG = LoggerFactory.getLogger(ClusterService.class);
public class AtlasServerService {
private static final Logger LOG = LoggerFactory.getLogger(AtlasServerService.class);
private final DataAccess dataAccess;
private final AtlasEntityStore entityStore;
......@@ -51,46 +51,68 @@ public class ClusterService {
private final EntityGraphRetriever entityGraphRetriever;
@Inject
public ClusterService(DataAccess dataAccess, AtlasEntityStore entityStore, AtlasTypeRegistry typeRegistry, EntityGraphRetriever entityGraphRetriever) {
public AtlasServerService(DataAccess dataAccess, AtlasEntityStore entityStore,
AtlasTypeRegistry typeRegistry,
EntityGraphRetriever entityGraphRetriever) {
this.dataAccess = dataAccess;
this.entityStore = entityStore;
this.typeRegistry = typeRegistry;
this.entityGraphRetriever = entityGraphRetriever;
}
public AtlasCluster get(AtlasCluster cluster) throws AtlasBaseException {
public AtlasServer get(AtlasServer server) throws AtlasBaseException {
try {
return dataAccess.load(cluster);
return dataAccess.load(server);
} catch (AtlasBaseException e) {
LOG.error("dataAccess", e);
throw e;
}
}
public AtlasServer getCreateAtlasServer(String name, String fullName) throws AtlasBaseException {
AtlasServer defaultServer = new AtlasServer(name, fullName);
AtlasServer server = getAtlasServer(defaultServer);
if (server == null) {
return save(defaultServer);
}
return server;
}
private AtlasServer getAtlasServer(AtlasServer server) {
try {
return get(server);
} catch (AtlasBaseException ex) {
return null;
}
}
@GraphTransaction
public AtlasCluster save(AtlasCluster clusterInfo) {
public AtlasServer save(AtlasServer server) {
try {
return dataAccess.save(clusterInfo);
return dataAccess.save(server);
} catch (AtlasBaseException e) {
return clusterInfo;
return server;
}
}
@GraphTransaction
public void updateEntitiesWithCluster(AtlasCluster cluster, List<String> entityGuids, String attributeName) throws AtlasBaseException {
if (cluster != null && StringUtils.isEmpty(cluster.getGuid())) {
public void updateEntitiesWithServer(AtlasServer server, List<String> entityGuids, String attributeName) throws AtlasBaseException {
if (server != null && StringUtils.isEmpty(server.getGuid())) {
return;
}
AtlasObjectId objectId = getObjectId(cluster);
AtlasObjectId objectId = getObjectId(server);
for (String guid : entityGuids) {
AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = entityStore.getById(guid);
updateAttribute(entityWithExtInfo, attributeName, objectId);
}
}
private AtlasObjectId getObjectId(AtlasCluster cluster) {
return new AtlasObjectId(cluster.getGuid(), AtlasCluster.class.getSimpleName());
private AtlasObjectId getObjectId(AtlasServer server) {
return new AtlasObjectId(server.getGuid(), AtlasServer.class.getSimpleName());
}
......
......@@ -22,7 +22,7 @@ import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasConstants;
import org.apache.atlas.AtlasException;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasCluster;
import org.apache.atlas.model.impexp.AtlasServer;
import org.apache.atlas.model.impexp.AtlasExportRequest;
import org.apache.atlas.model.impexp.AtlasExportResult;
import org.apache.atlas.model.impexp.AtlasImportRequest;
......@@ -45,15 +45,15 @@ public class AuditsWriter {
private static final Logger LOG = LoggerFactory.getLogger(AuditsWriter.class);
private static final String CLUSTER_NAME_DEFAULT = "default";
private ClusterService clusterService;
private AtlasServerService atlasServerService;
private ExportImportAuditService auditService;
private ExportAudits auditForExport = new ExportAudits();
private ImportAudits auditForImport = new ImportAudits();
@Inject
public AuditsWriter(ClusterService clusterService, ExportImportAuditService auditService) {
this.clusterService = clusterService;
public AuditsWriter(AtlasServerService atlasServerService, ExportImportAuditService auditService) {
this.atlasServerService = atlasServerService;
this.auditService = auditService;
}
......@@ -63,7 +63,9 @@ public class AuditsWriter {
auditForExport.add(userName, result, startTime, endTime, entityCreationOrder);
}
public void write(String userName, AtlasImportResult result, long startTime, long endTime, List<String> entityCreationOrder) throws AtlasBaseException {
public void write(String userName, AtlasImportResult result,
long startTime, long endTime,
List<String> entityCreationOrder) throws AtlasBaseException {
auditForImport.add(userName, result, startTime, endTime, entityCreationOrder);
}
......@@ -72,7 +74,7 @@ public class AuditsWriter {
}
private void updateReplicationAttribute(boolean isReplicationSet,
String clusterName,
String serverName,
List<String> exportedGuids,
String attrNameReplicated,
long lastModifiedTimestamp) throws AtlasBaseException {
......@@ -80,30 +82,32 @@ public class AuditsWriter {
return;
}
AtlasCluster cluster = saveCluster(clusterName, exportedGuids.get(0), lastModifiedTimestamp);
clusterService.updateEntitiesWithCluster(cluster, exportedGuids, attrNameReplicated);
AtlasServer server = saveServer(serverName, exportedGuids.get(0), lastModifiedTimestamp);
atlasServerService.updateEntitiesWithServer(server, exportedGuids, attrNameReplicated);
}
private String getClusterNameFromOptions(Map options, String key) {
return options.containsKey(key)
? (String) options.get(key)
: "";
: StringUtils.EMPTY;
}
private AtlasCluster saveCluster(String clusterName) throws AtlasBaseException {
AtlasCluster cluster = new AtlasCluster(clusterName, clusterName);
return clusterService.save(cluster);
private AtlasServer saveServer(String name) throws AtlasBaseException {
return atlasServerService.save(new AtlasServer(name, name));
}
private AtlasCluster saveCluster(String clusterName, String entityGuid, long lastModifiedTimestamp) throws AtlasBaseException {
AtlasCluster cluster = new AtlasCluster(clusterName, clusterName);
cluster.setAdditionalInfoRepl(entityGuid, lastModifiedTimestamp);
private AtlasServer saveServer(String name,
String entityGuid,
long lastModifiedTimestamp) throws AtlasBaseException {
AtlasServer server = new AtlasServer(name, name);
server.setAdditionalInfoRepl(entityGuid, lastModifiedTimestamp);
if (LOG.isDebugEnabled()) {
LOG.debug("saveCluster: {}", cluster);
LOG.debug("saveServer: {}", server);
}
return clusterService.save(cluster);
return atlasServerService.save(server);
}
public static String getCurrentClusterName() {
......@@ -113,12 +117,12 @@ public class AuditsWriter {
LOG.error("getCurrentClusterName", e);
}
return "";
return StringUtils.EMPTY;
}
private class ExportAudits {
private AtlasExportRequest request;
private String targetClusterName;
private String targetServerName;
private String optionKeyReplicatedTo;
private boolean replicationOptionState;
......@@ -129,9 +133,9 @@ public class AuditsWriter {
request = result.getRequest();
replicationOptionState = isReplicationOptionSet(request.getOptions(), optionKeyReplicatedTo);
saveClusters();
saveServers();
auditService.add(userName, getCurrentClusterName(), targetClusterName,
auditService.add(userName, getCurrentClusterName(), targetServerName,
ExportImportAuditEntry.OPERATION_EXPORT,
AtlasType.toJson(result), startTime, endTime, !entityGuids.isEmpty());
......@@ -139,16 +143,16 @@ public class AuditsWriter {
return;
}
updateReplicationAttribute(replicationOptionState, targetClusterName,
entityGuids, Constants.ATTR_NAME_REPLICATED_TO_CLUSTER, result.getLastModifiedTimestamp());
updateReplicationAttribute(replicationOptionState, targetServerName,
entityGuids, Constants.ATTR_NAME_REPLICATED_TO, result.getLastModifiedTimestamp());
}
private void saveClusters() throws AtlasBaseException {
saveCluster(getCurrentClusterName());
private void saveServers() throws AtlasBaseException {
saveServer(getCurrentClusterName());
targetClusterName = getClusterNameFromOptions(request.getOptions(), optionKeyReplicatedTo);
if(StringUtils.isNotEmpty(targetClusterName)) {
saveCluster(targetClusterName);
targetServerName = getClusterNameFromOptions(request.getOptions(), optionKeyReplicatedTo);
if(StringUtils.isNotEmpty(targetServerName)) {
saveServer(targetServerName);
}
}
}
......@@ -156,8 +160,7 @@ public class AuditsWriter {
private class ImportAudits {
private AtlasImportRequest request;
private boolean replicationOptionState;
private String sourceClusterName;
private AtlasCluster sourceCluster;
private String sourceServerName;
private String optionKeyReplicatedFrom;
public void add(String userName, AtlasImportResult result,
......@@ -167,10 +170,10 @@ public class AuditsWriter {
request = result.getRequest();
replicationOptionState = isReplicationOptionSet(request.getOptions(), optionKeyReplicatedFrom);
saveClusters();
saveServers();
auditService.add(userName,
sourceClusterName, getCurrentClusterName(),
sourceServerName, getCurrentClusterName(),
ExportImportAuditEntry.OPERATION_IMPORT,
AtlasType.toJson(result), startTime, endTime, !entityGuids.isEmpty());
......@@ -178,23 +181,23 @@ public class AuditsWriter {
return;
}
updateReplicationAttribute(replicationOptionState, this.sourceClusterName, entityGuids,
Constants.ATTR_NAME_REPLICATED_FROM_CLUSTER, result.getExportResult().getLastModifiedTimestamp());
updateReplicationAttribute(replicationOptionState, this.sourceServerName, entityGuids,
Constants.ATTR_NAME_REPLICATED_FROM, result.getExportResult().getLastModifiedTimestamp());
}
private void saveClusters() throws AtlasBaseException {
saveCluster(getCurrentClusterName());
private void saveServers() throws AtlasBaseException {
saveServer(getCurrentClusterName());
sourceClusterName = getClusterNameFromOptionsState();
if(StringUtils.isNotEmpty(sourceClusterName)) {
this.sourceCluster = saveCluster(sourceClusterName);
sourceServerName = getClusterNameFromOptionsState();
if(StringUtils.isNotEmpty(sourceServerName)) {
saveServer(sourceServerName);
}
}
private String getClusterNameFromOptionsState() {
return replicationOptionState
? getClusterNameFromOptions(request.getOptions(), optionKeyReplicatedFrom)
: "";
: StringUtils.EMPTY;
}
}
}
......@@ -120,10 +120,10 @@ public class ExportImportAuditService {
addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_START_TIME, startTime);
addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_END_TIME, endTime);
addClusterFilterCriteria(criteria, cluster);
addServerFilterCriteria(criteria, cluster);
}
private void addClusterFilterCriteria(SearchParameters.FilterCriteria parentCriteria, String cluster) {
private void addServerFilterCriteria(SearchParameters.FilterCriteria parentCriteria, String cluster) {
if (StringUtils.isEmpty(cluster)) {
return;
}
......@@ -132,8 +132,8 @@ public class ExportImportAuditService {
criteria.setCondition(SearchParameters.FilterCriteria.Condition.OR);
criteria.setCriterion(new ArrayList<>());
addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_SOURCE_CLUSTER_NAME, cluster);
addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_TARGET_CLUSTER_NAME, cluster);
addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_SOURCE_SERVER_NAME, cluster);
addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_TARGET_SERVER_NAME, cluster);
parentCriteria.getCriterion().add(criteria);
}
......@@ -158,8 +158,8 @@ public class ExportImportAuditService {
ExportImportAuditEntry entry = new ExportImportAuditEntry();
entry.setUserName(userName);
entry.setSourceClusterName(sourceCluster);
entry.setTargetClusterName(targetCluster);
entry.setSourceServerName(sourceCluster);
entry.setTargetServerName(targetCluster);
entry.setOperation(operation);
entry.setResultSummary(result);
entry.setStartTime(startTime);
......@@ -167,6 +167,6 @@ public class ExportImportAuditService {
save(entry);
LOG.info("addAuditEntry: user: {}, source: {}, target: {}, operation: {}", entry.getUserName(),
entry.getSourceClusterName(), entry.getTargetClusterName(), entry.getOperation());
entry.getSourceServerName(), entry.getTargetServerName(), entry.getOperation());
}
}
......@@ -18,7 +18,7 @@
package org.apache.atlas.repository.ogm;
import org.apache.atlas.model.impexp.AtlasCluster;
import org.apache.atlas.model.impexp.AtlasServer;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.springframework.stereotype.Component;
......@@ -29,39 +29,42 @@ import java.util.List;
import java.util.Map;
@Component
public class AtlasClusterDTO extends AbstractDataTransferObject<AtlasCluster> {
private final String PROPERTY_CLUSTER_NAME = "displayName";
private final String PROPERTY_QUALIFIED_NAME = "qualifiedName";
public class AtlasServerDTO extends AbstractDataTransferObject<AtlasServer> {
private final String PROPERTY_NAME = "name";
private final String PROPERTY_DISPLAY_NAME = "displayName";
private final String PROPERTY_FULL_NAME = "fullName";
private final String PROPERTY_ADDITIONAL_INFO = "additionalInfo";
private final String PROPERTY_URLS = "urls";
@Inject
public AtlasClusterDTO(AtlasTypeRegistry typeRegistry) {
super(typeRegistry, AtlasCluster.class, AtlasCluster.class.getSimpleName());
public AtlasServerDTO(AtlasTypeRegistry typeRegistry) {
super(typeRegistry, AtlasServer.class, AtlasServer.class.getSimpleName());
}
public AtlasCluster from(AtlasEntity entity) {
AtlasCluster cluster = new AtlasCluster();
public AtlasServer from(AtlasEntity entity) {
AtlasServer cluster = new AtlasServer();
setGuid(cluster, entity);
cluster.setName((String) entity.getAttribute(PROPERTY_CLUSTER_NAME));
cluster.setQualifiedName((String) entity.getAttribute(PROPERTY_QUALIFIED_NAME));
cluster.setName((String) entity.getAttribute(PROPERTY_NAME));
cluster.setFullName((String) entity.getAttribute(PROPERTY_FULL_NAME));
cluster.setDisplayName((String) entity.getAttribute(PROPERTY_DISPLAY_NAME));
cluster.setAdditionalInfo((Map<String,String>) entity.getAttribute(PROPERTY_ADDITIONAL_INFO));
cluster.setUrls((List<String>) entity.getAttribute(PROPERTY_URLS));
return cluster;
}
public AtlasCluster from(AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo) {
public AtlasServer from(AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo) {
return from(entityWithExtInfo.getEntity());
}
@Override
public AtlasEntity toEntity(AtlasCluster obj) {
public AtlasEntity toEntity(AtlasServer obj) {
AtlasEntity entity = getDefaultAtlasEntity(obj);
entity.setAttribute(PROPERTY_CLUSTER_NAME, obj.getName());
entity.setAttribute(PROPERTY_QUALIFIED_NAME, obj.getQualifiedName());
entity.setAttribute(PROPERTY_NAME, obj.getName());
entity.setAttribute(PROPERTY_DISPLAY_NAME, obj.getDisplayName());
entity.setAttribute(PROPERTY_FULL_NAME, obj.getFullName());
entity.setAttribute(PROPERTY_ADDITIONAL_INFO, obj.getAdditionalInfo());
entity.setAttribute(PROPERTY_URLS, obj.getUrls());
......@@ -69,14 +72,14 @@ public class AtlasClusterDTO extends AbstractDataTransferObject<AtlasCluster> {
}
@Override
public AtlasEntity.AtlasEntityWithExtInfo toEntityWithExtInfo(AtlasCluster obj) {
public AtlasEntity.AtlasEntityWithExtInfo toEntityWithExtInfo(AtlasServer obj) {
return new AtlasEntity.AtlasEntityWithExtInfo(toEntity(obj));
}
@Override
public Map<String, Object> getUniqueAttributes(final AtlasCluster obj) {
public Map<String, Object> getUniqueAttributes(final AtlasServer obj) {
return new HashMap<String, Object>() {{
put(PROPERTY_QUALIFIED_NAME, obj.getQualifiedName());
put(PROPERTY_FULL_NAME, obj.getFullName());
}};
}
}
......@@ -40,14 +40,14 @@ public class ExportImportAuditEntryDTO extends AbstractDataTransferObject<Export
public static final String PROPERTY_START_TIME = "operationStartTime";
public static final String PROPERTY_END_TIME = "operationEndTime";
public static final String PROPERTY_RESULT_SUMMARY = "resultSummary";
public static final String PROPERTY_SOURCE_CLUSTER_NAME = "sourceClusterName";
public static final String PROPERTY_TARGET_CLUSTER_NAME = "targetClusterName";
public static final String PROPERTY_SOURCE_SERVER_NAME = "sourceServerName";
public static final String PROPERTY_TARGET_SERVER_NAME = "targetServerName";
private static final Set<String> ATTRIBUTE_NAMES = new HashSet<>(Arrays.asList(PROPERTY_USER_NAME,
PROPERTY_OPERATION, PROPERTY_OPERATION_PARAMS,
PROPERTY_START_TIME, PROPERTY_END_TIME,
PROPERTY_RESULT_SUMMARY,
PROPERTY_SOURCE_CLUSTER_NAME, PROPERTY_TARGET_CLUSTER_NAME));
PROPERTY_SOURCE_SERVER_NAME, PROPERTY_TARGET_SERVER_NAME));
@Inject
public ExportImportAuditEntryDTO(AtlasTypeRegistry typeRegistry) {
......@@ -68,8 +68,8 @@ public class ExportImportAuditEntryDTO extends AbstractDataTransferObject<Export
entry.setOperationParams((String) attributes.get(PROPERTY_OPERATION_PARAMS));
entry.setStartTime((long) attributes.get(PROPERTY_START_TIME));
entry.setEndTime((long) attributes.get(PROPERTY_END_TIME));
entry.setSourceClusterName((String) attributes.get(PROPERTY_SOURCE_CLUSTER_NAME));
entry.setTargetClusterName((String) attributes.get(PROPERTY_TARGET_CLUSTER_NAME));
entry.setSourceServerName((String) attributes.get(PROPERTY_SOURCE_SERVER_NAME));
entry.setTargetServerName((String) attributes.get(PROPERTY_TARGET_SERVER_NAME));
entry.setResultSummary((String) attributes.get(PROPERTY_RESULT_SUMMARY));
return entry;
......@@ -94,8 +94,8 @@ public class ExportImportAuditEntryDTO extends AbstractDataTransferObject<Export
entity.setAttribute(PROPERTY_OPERATION_PARAMS, obj.getOperationParams());
entity.setAttribute(PROPERTY_START_TIME, obj.getStartTime());
entity.setAttribute(PROPERTY_END_TIME, obj.getEndTime());
entity.setAttribute(PROPERTY_SOURCE_CLUSTER_NAME, obj.getSourceClusterName());
entity.setAttribute(PROPERTY_TARGET_CLUSTER_NAME, obj.getTargetClusterName());
entity.setAttribute(PROPERTY_SOURCE_SERVER_NAME, obj.getSourceServerName());
entity.setAttribute(PROPERTY_TARGET_SERVER_NAME, obj.getTargetServerName());
entity.setAttribute(PROPERTY_RESULT_SUMMARY, obj.getResultSummary());
return entity;
......
......@@ -41,7 +41,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.GraphDBMigrator;
import org.apache.atlas.repository.graphdb.janus.migration.GraphDBGraphSONMigrator;
import org.apache.atlas.repository.impexp.ExportService;
import org.apache.atlas.repository.ogm.AtlasClusterDTO;
import org.apache.atlas.repository.ogm.AtlasServerDTO;
import org.apache.atlas.repository.ogm.ExportImportAuditEntryDTO;
import org.apache.atlas.repository.ogm.profiles.AtlasSavedSearchDTO;
import org.apache.atlas.repository.ogm.profiles.AtlasUserProfileDTO;
......@@ -172,7 +172,7 @@ public class TestModules {
availableDTOs.addBinding().to(AtlasGlossaryDTO.class);
availableDTOs.addBinding().to(AtlasGlossaryTermDTO.class);
availableDTOs.addBinding().to(AtlasGlossaryCategoryDTO.class);
availableDTOs.addBinding().to(AtlasClusterDTO.class);
availableDTOs.addBinding().to(AtlasServerDTO.class);
availableDTOs.addBinding().to(ExportImportAuditEntryDTO.class);
bind(DTORegistry.class).asEagerSingleton();
......
......@@ -20,7 +20,7 @@ package org.apache.atlas.repository.impexp;
import org.apache.atlas.TestModules;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasCluster;
import org.apache.atlas.model.impexp.AtlasServer;
import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.store.AtlasTypeDefStore;
......@@ -41,13 +41,12 @@ import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
@Guice(modules = TestModules.TestOnlyModule.class)
public class ClusterServiceTest {
private final String TOP_LEVEL_ENTITY_NAME = "db1@cl1";
private final String CLUSTER_NAME = "testCl1";
private final String TARGET_CLUSTER_NAME = "testCl2";
private final String QUALIFIED_NAME_STOCKS = "stocks@cl1";
private final String TYPE_HIVE_DB = "hive_db";
private final String topLevelEntityGuid = "AAA-BBB-CCC";
public class AtlasServerServiceTest {
private final String TOP_LEVEL_ENTITY_NAME = "db1@cl1";
private final String SERVER_NAME = "testCl1";
private final String TARGET_SERVER_NAME = "testCl2";
private final String QUALIFIED_NAME_STOCKS = "stocks@cl1";
private final String TYPE_HIVE_DB = "hive_db";
@Inject
private AtlasTypeDefStore typeDefStore;
......@@ -56,7 +55,8 @@ public class ClusterServiceTest {
private AtlasTypeRegistry typeRegistry;
@Inject
private ClusterService clusterService;
private AtlasServerService atlasServerService;
private String topLevelEntityGuid = "AAA-BBB-CCC";
@BeforeClass
public void setup() throws IOException, AtlasBaseException {
......@@ -64,15 +64,15 @@ public class ClusterServiceTest {
}
@Test
public void saveAndRetrieveClusterInfo() throws AtlasBaseException {
AtlasCluster expected = getCluster(CLUSTER_NAME + "_1", TOP_LEVEL_ENTITY_NAME, "EXPORT", 0l, TARGET_CLUSTER_NAME);
AtlasCluster expected2 = getCluster(TARGET_CLUSTER_NAME + "_1", TOP_LEVEL_ENTITY_NAME, "IMPORT", 0L, TARGET_CLUSTER_NAME);
AtlasCluster expected3 = getCluster(TARGET_CLUSTER_NAME + "_3", TOP_LEVEL_ENTITY_NAME, "IMPORT", 0, TARGET_CLUSTER_NAME);
public void saveAndRetrieveServerInfo() throws AtlasBaseException {
AtlasServer expected = getServer(SERVER_NAME + "_1", TOP_LEVEL_ENTITY_NAME, "EXPORT", 0l, TARGET_SERVER_NAME);
AtlasServer expected2 = getServer(TARGET_SERVER_NAME + "_1", TOP_LEVEL_ENTITY_NAME, "IMPORT", 0L, TARGET_SERVER_NAME);
AtlasServer expected3 = getServer(TARGET_SERVER_NAME + "_3", TOP_LEVEL_ENTITY_NAME, "IMPORT", 0, TARGET_SERVER_NAME);
AtlasCluster actual = clusterService.save(expected);
AtlasCluster actual2 = clusterService.save(expected2);
AtlasCluster actual3 = clusterService.save(expected3);
AtlasCluster actual2x = clusterService.get(expected2);
AtlasServer actual = atlasServerService.save(expected);
AtlasServer actual2 = atlasServerService.save(expected2);
AtlasServer actual3 = atlasServerService.save(expected3);
AtlasServer actual2x = atlasServerService.get(expected2);
assertNotNull(actual.getGuid());
assertNotNull(actual2.getGuid());
......@@ -83,18 +83,18 @@ public class ClusterServiceTest {
assertEquals(actual.getName(), expected.getName());
assertEquals(actual.getQualifiedName(), expected.getQualifiedName());
assertEquals(actual.getFullName(), expected.getFullName());
}
private AtlasCluster getCluster(String clusterName, String topLevelEntity, String operation, long nextModifiedTimestamp, String targetClusterName) {
AtlasCluster cluster = new AtlasCluster(clusterName, clusterName);
private AtlasServer getServer(String serverName, String topLevelEntity, String operation, long nextModifiedTimestamp, String targetServerName) {
AtlasServer cluster = new AtlasServer(serverName, serverName);
Map<String, String> syncMap = new HashMap<>();
syncMap.put("topLevelEntity", topLevelEntity);
syncMap.put("operation", operation);
syncMap.put("nextModifiedTimestamp", Long.toString(nextModifiedTimestamp));
syncMap.put("targetCluster", targetClusterName);
syncMap.put("targetCluster", targetServerName);
cluster.setAdditionalInfo(syncMap);
......@@ -105,13 +105,13 @@ public class ClusterServiceTest {
public void verifyAdditionalInfo() throws AtlasBaseException {
final long expectedLastModifiedTimestamp = 200L;
AtlasCluster expectedCluster = new AtlasCluster(CLUSTER_NAME, CLUSTER_NAME);
AtlasServer expectedCluster = atlasServerService.getCreateAtlasServer(SERVER_NAME, SERVER_NAME);
String qualifiedNameAttr = Constants.QUALIFIED_NAME.replace(ATTR_NAME_REFERENCEABLE, "");
AtlasObjectId objectId = new AtlasObjectId(TYPE_HIVE_DB, qualifiedNameAttr, QUALIFIED_NAME_STOCKS);
expectedCluster.setAdditionalInfoRepl(topLevelEntityGuid, expectedLastModifiedTimestamp);
AtlasCluster actualCluster = clusterService.save(expectedCluster);
AtlasServer actualCluster = atlasServerService.save(expectedCluster);
assertEquals(actualCluster.getName(), expectedCluster.getName());
int actualModifiedTimestamp = (int) actualCluster.getAdditionalInfoRepl(topLevelEntityGuid);
......
......@@ -76,14 +76,14 @@ public class ExportImportAuditServiceTest extends ExportImportTestBase {
assertNotEquals(actualEntry.getGuid(), actualEntry2.getGuid());
assertNotNull(actualEntry.getGuid());
assertEquals(actualEntry.getSourceClusterName(), entry.getSourceClusterName());
assertEquals(actualEntry.getTargetClusterName(), entry.getTargetClusterName());
assertEquals(actualEntry.getSourceServerName(), entry.getSourceServerName());
assertEquals(actualEntry.getTargetServerName(), entry.getTargetServerName());
assertEquals(actualEntry.getOperation(), entry.getOperation());
}
@Test
public void numberOfSavedEntries_Retrieved() throws AtlasBaseException, InterruptedException {
final String source1 = "cluster1";
final String source1 = "server1";
final String target1 = "cly";
int MAX_ENTRIES = 5;
......@@ -100,7 +100,7 @@ public class ExportImportAuditServiceTest extends ExportImportTestBase {
private ExportImportAuditEntry retrieveEntry(ExportImportAuditEntry entry) throws AtlasBaseException {
List<ExportImportAuditEntry> result = auditService.get(entry.getUserName(), entry.getOperation(),
entry.getSourceClusterName(),
entry.getSourceServerName(),
Long.toString(entry.getStartTime()), "", 10, 0);
assertNotNull(result);
assertEquals(result.size(), 1);
......@@ -108,10 +108,10 @@ public class ExportImportAuditServiceTest extends ExportImportTestBase {
return auditService.get(entry);
}
private ExportImportAuditEntry saveAndGet(String sourceClusterName, String operation, String targetClusterName) throws AtlasBaseException {
ExportImportAuditEntry entry = new ExportImportAuditEntry(sourceClusterName, operation);
private ExportImportAuditEntry saveAndGet(String sourceServerName, String operation, String targetServerName) throws AtlasBaseException {
ExportImportAuditEntry entry = new ExportImportAuditEntry(sourceServerName, operation);
entry.setTargetClusterName(targetClusterName);
entry.setTargetServerName(targetServerName);
entry.setUserName("default");
entry.setStartTime(System.currentTimeMillis());
entry.setEndTime(System.currentTimeMillis() + 1000L);
......
......@@ -24,7 +24,7 @@ import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules;
import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasCluster;
import org.apache.atlas.model.impexp.AtlasServer;
import org.apache.atlas.model.impexp.AtlasExportRequest;
import org.apache.atlas.model.impexp.AtlasImportRequest;
import org.apache.atlas.model.impexp.AtlasImportResult;
......@@ -63,9 +63,6 @@ public class ReplicationEntityAttributeTest extends ExportImportTestBase {
private final String EXPORT_REQUEST_FILE = "export-replicatedTo";
private final String IMPORT_REQUEST_FILE = "import-replicatedFrom";
private final String DB_GUID = "1637a33e-6512-447b-ade7-249c8cb5344b";
private final String TABLE_GUID = "df122fc3-5555-40f8-a30f-3090b8a622f8";
private String REPLICATED_TO_CLUSTER_NAME = "";
private String REPLICATED_FROM_CLUSTER_NAME = "";
......@@ -85,7 +82,7 @@ public class ReplicationEntityAttributeTest extends ExportImportTestBase {
ImportService importService;
@Inject
ClusterService clusterService;
AtlasServerService atlasServerService;
private AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class);
private AtlasEntityStoreV2 entityStore;
......@@ -120,7 +117,7 @@ public class ReplicationEntityAttributeTest extends ExportImportTestBase {
assertEquals(zipSource.getCreationOrder().size(), expectedEntityCount);
assertCluster(REPLICATED_TO_CLUSTER_NAME, null);
assertReplicationAttribute(Constants.ATTR_NAME_REPLICATED_TO_CLUSTER);
assertReplicationAttribute(Constants.ATTR_NAME_REPLICATED_TO);
}
@Test(dependsOnMethods = "exportWithReplicationToOption_AddsClusterObjectIdToReplicatedFromAttribute", enabled = false)
......@@ -129,7 +126,7 @@ public class ReplicationEntityAttributeTest extends ExportImportTestBase {
AtlasImportResult importResult = runImportWithParameters(importService, request, zipSource);
assertCluster(REPLICATED_FROM_CLUSTER_NAME, importResult);
assertReplicationAttribute(Constants.ATTR_NAME_REPLICATED_FROM_CLUSTER);
assertReplicationAttribute(Constants.ATTR_NAME_REPLICATED_FROM);
}
private void assertReplicationAttribute(String attrNameReplication) throws AtlasBaseException {
......@@ -139,13 +136,13 @@ public class ReplicationEntityAttributeTest extends ExportImportTestBase {
Object ex = e.getAttribute(attrNameReplication);
assertNotNull(ex);
List<String> clusterNameSyncType = (List) ex;
assertEquals(clusterNameSyncType.size(), 1);
List<String> attrValue = (List) ex;
assertEquals(attrValue.size(), 1);
}
}
private void assertCluster(String name, AtlasImportResult importResult) throws AtlasBaseException {
AtlasCluster actual = clusterService.get(new AtlasCluster(name, name));
AtlasServer actual = atlasServerService.get(new AtlasServer(name, name));
assertNotNull(actual);
assertEquals(actual.getName(), name);
......@@ -155,7 +152,7 @@ public class ReplicationEntityAttributeTest extends ExportImportTestBase {
}
}
private void assertClusterAdditionalInfo(AtlasCluster cluster, AtlasImportResult importResult) throws AtlasBaseException {
private void assertClusterAdditionalInfo(AtlasServer cluster, AtlasImportResult importResult) throws AtlasBaseException {
AtlasExportRequest request = importResult.getExportResult().getRequest();
AtlasEntityType type = (AtlasEntityType) typeRegistry.getType(request.getItemsToExport().get(0).getTypeName());
AtlasEntity.AtlasEntityWithExtInfo entity = entityStore.getByUniqueAttributes(type, request.getItemsToExport().get(0).getUniqueAttributes());
......
{
"name": "replicatedFromCluster",
"typeName": "array<AtlasCluster>",
"name": "replicatedFrom",
"typeName": "array<AtlasServer>",
"cardinality": "SET",
"isIndexable": false,
"isOptional": true,
......
......@@ -29,18 +29,21 @@ import org.apache.atlas.authorize.AtlasAuthorizationUtils;
import org.apache.atlas.discovery.SearchContext;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.impexp.AtlasServer;
import org.apache.atlas.model.impexp.AtlasExportRequest;
import org.apache.atlas.model.impexp.AtlasExportResult;
import org.apache.atlas.model.impexp.AtlasImportRequest;
import org.apache.atlas.model.impexp.AtlasImportResult;
import org.apache.atlas.model.impexp.*;
import org.apache.atlas.model.impexp.ExportImportAuditEntry;
import org.apache.atlas.model.impexp.MigrationStatus;
import org.apache.atlas.model.metrics.AtlasMetrics;
import org.apache.atlas.repository.impexp.AtlasServerService;
import org.apache.atlas.repository.impexp.ExportImportAuditService;
import org.apache.atlas.repository.impexp.ExportService;
import org.apache.atlas.repository.impexp.ImportService;
import org.apache.atlas.repository.impexp.MigrationProgressService;
import org.apache.atlas.repository.impexp.ZipSink;
import org.apache.atlas.repository.impexp.ZipSource;
import org.apache.atlas.repository.impexp.ExportImportAuditService;
import org.apache.atlas.repository.impexp.*;
import org.apache.atlas.services.MetricsService;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
......@@ -126,10 +129,10 @@ public class AdminResource {
private final ImportService importService;
private final SearchTracker activeSearches;
private final AtlasTypeRegistry typeRegistry;
private final MigrationProgressService migrationProgressService;
private final MigrationProgressService migrationProgressService;
private final ReentrantLock importExportOperationLock;
private final ExportImportAuditService exportImportAuditService;
private final ClusterService clusterService;
private final AtlasServerService atlasServerService;
static {
try {
......@@ -143,7 +146,7 @@ public class AdminResource {
public AdminResource(ServiceState serviceState, MetricsService metricsService, AtlasTypeRegistry typeRegistry,
ExportService exportService, ImportService importService, SearchTracker activeSearches,
MigrationProgressService migrationProgressService,
ClusterService clusterService,
AtlasServerService serverService,
ExportImportAuditService exportImportAuditService) {
this.serviceState = serviceState;
this.metricsService = metricsService;
......@@ -152,7 +155,7 @@ public class AdminResource {
this.activeSearches = activeSearches;
this.typeRegistry = typeRegistry;
this.migrationProgressService = migrationProgressService;
this.clusterService = clusterService;
this.atlasServerService = serverService;
this.exportImportAuditService = exportImportAuditService;
this.importExportOperationLock = new ReentrantLock();
}
......@@ -448,24 +451,24 @@ public class AdminResource {
/**
* Fetch details of a cluster.
* @param clusterName name of target cluster with which it is paired
* @return AtlasCluster
* @param serverName name of target cluster with which it is paired
* @return AtlasServer
* @throws AtlasBaseException
*/
@GET
@Path("/cluster/{clusterName}")
@Path("/server/{serverName}")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasCluster getCluster(@PathParam("clusterName") String clusterName) throws AtlasBaseException {
public AtlasServer getCluster(@PathParam("serverName") String serverName) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "cluster.getCluster(" + clusterName + ")");
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "cluster.getServer(" + serverName + ")");
}
AtlasCluster cluster = new AtlasCluster(clusterName, clusterName);
return clusterService.get(cluster);
AtlasServer cluster = new AtlasServer(serverName, serverName);
return atlasServerService.get(cluster);
} finally {
AtlasPerfTracer.log(perf);
}
......@@ -475,7 +478,7 @@ public class AdminResource {
@Path("/expimp/audit")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public List<ExportImportAuditEntry> getExportImportAudit(@QueryParam("clusterName") String cluster,
public List<ExportImportAuditEntry> getExportImportAudit(@QueryParam("serverName") String serverName,
@QueryParam("userName") String userName,
@QueryParam("operation") String operation,
@QueryParam("startTime") String startTime,
......@@ -486,10 +489,10 @@ public class AdminResource {
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "getExportImportAudit(" + cluster + ")");
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "getExportImportAudit(" + serverName + ")");
}
return exportImportAuditService.get(userName, operation, cluster, startTime, endTime, limit, offset);
return exportImportAuditService.get(userName, operation, serverName, startTime, endTime, limit, offset);
} finally {
AtlasPerfTracer.log(perf);
}
......
......@@ -21,7 +21,7 @@ package org.apache.atlas.web.resources;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasCluster;
import org.apache.atlas.model.impexp.AtlasServer;
import org.apache.atlas.model.impexp.AtlasExportRequest;
import org.apache.atlas.model.impexp.AtlasImportRequest;
import org.apache.atlas.model.impexp.AtlasImportResult;
......@@ -44,10 +44,10 @@ import static org.testng.Assert.assertTrue;
public class AdminExportImportTestIT extends BaseResourceIT {
private final String FILE_TO_IMPORT = "stocks-base.zip";
private final String EXPORT_REQUEST_FILE = "export-incremental";
private final String SOURCE_CLUSTER_NAME = "cl1";
private final String SOURCE_SERVER_NAME = "cl1";
static final String IMPORT_TRANSFORM_CLEAR_ATTRS =
"{ \"Asset\": { \"*\":[ \"clearAttrValue:replicatedToCluster,replicatedFromCluster\" ] } }";
"{ \"Asset\": { \"*\":[ \"clearAttrValue:replicatedTo,replicatedFrom\" ] } }";
static final String IMPORT_TRANSFORM_SET_DELETED =
"{ \"Asset\": { \"*\":[ \"setDeleted\" ] } }";
......@@ -77,7 +77,7 @@ public class AdminExportImportTestIT extends BaseResourceIT {
private void performImport(String fileToImport) throws AtlasServiceException {
AtlasImportRequest request = new AtlasImportRequest();
request.getOptions().put(AtlasImportRequest.OPTION_KEY_REPLICATED_FROM, SOURCE_CLUSTER_NAME);
request.getOptions().put(AtlasImportRequest.OPTION_KEY_REPLICATED_FROM, SOURCE_SERVER_NAME);
request.getOptions().put(AtlasImportRequest.TRANSFORMS_KEY, IMPORT_TRANSFORM_CLEAR_ATTRS);
performImport(fileToImport, request);
......@@ -100,11 +100,11 @@ public class AdminExportImportTestIT extends BaseResourceIT {
assertEquals(result.getProcessedEntities().size(), 37);
}
private void assertReplicationData(String clusterName) throws AtlasServiceException {
AtlasCluster cluster = atlasClientV2.getCluster(clusterName);
assertNotNull(cluster);
assertNotNull(cluster.getAdditionalInfo());
assertTrue(cluster.getAdditionalInfo().size() > 0);
private void assertReplicationData(String serverName) throws AtlasServiceException {
AtlasServer server = atlasClientV2.getServer(serverName);
assertNotNull(server);
assertNotNull(server.getAdditionalInfo());
assertTrue(server.getAdditionalInfo().size() > 0);
}
@AfterClass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment