Skip to content

Commit

Permalink
Merge pull request #2828 from atlanhq/startupTime2
Browse files Browse the repository at this point in the history
Reduce atlas startupTime
  • Loading branch information
aarshi0301 authored Feb 5, 2024
2 parents aaa1102 + 081bfd7 commit 91041df
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public ServicePolicies getPolicies(String serviceName, String pluginId, Long las
servicePolicies.setPolicyUpdateTime(new Date());

if (service != null) {
List<RangerPolicy> allPolicies = getServicePolicies(service);
List<RangerPolicy> allPolicies = getServicePolicies(service, 250);
servicePolicies.setServiceName(serviceName);
servicePolicies.setServiceId(service.getGuid());

Expand All @@ -162,7 +162,7 @@ public ServicePolicies getPolicies(String serviceName, String pluginId, Long las
AtlasEntityHeader tagService = getServiceEntity(tagServiceName);

if (tagService != null) {
allPolicies.addAll(getServicePolicies(tagService));
allPolicies.addAll(getServicePolicies(tagService, 0));

TagPolicies tagPolicies = new TagPolicies();

Expand Down Expand Up @@ -200,13 +200,13 @@ public ServicePolicies getPolicies(String serviceName, String pluginId, Long las
return servicePolicies;
}

private List<RangerPolicy> getServicePolicies(AtlasEntityHeader service) throws AtlasBaseException, IOException {
private List<RangerPolicy> getServicePolicies(AtlasEntityHeader service, int batchSize) throws AtlasBaseException, IOException {

List<RangerPolicy> servicePolicies = new ArrayList<>();

String serviceName = (String) service.getAttribute("name");
String serviceType = (String) service.getAttribute("authServiceType");
List<AtlasEntityHeader> atlasPolicies = getAtlasPolicies(serviceName);
List<AtlasEntityHeader> atlasPolicies = getAtlasPolicies(serviceName, batchSize);

if (CollectionUtils.isNotEmpty(atlasPolicies)) {
//transform policies
Expand Down Expand Up @@ -417,7 +417,7 @@ private List<RangerValiditySchedule> getPolicyValiditySchedule(AtlasEntityHeader
return ret;
}

private List<AtlasEntityHeader> getAtlasPolicies(String serviceName) throws AtlasBaseException {
private List<AtlasEntityHeader> getAtlasPolicies(String serviceName, int batchSize) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder recorder = RequestContext.get().startMetricRecord("CachePolicyTransformerImpl."+service+".getAtlasPolicies");

List<AtlasEntityHeader> ret = new ArrayList<>();
Expand Down Expand Up @@ -460,6 +460,10 @@ private List<AtlasEntityHeader> getAtlasPolicies(String serviceName) throws Atla

int from = 0;
int size = 100;

if (batchSize > 0) {
size = batchSize;
}
boolean found = true;

do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ public synchronized void init(Properties props, String appType) {
List<AuditHandler> providers = new ArrayList<AuditHandler>();

for (Object propNameObj : props.keySet()) {
LOG.info("AUDIT PROPERTY: " + propNameObj.toString() + "="
+ props.getProperty(propNameObj.toString()));
if (LOG.isDebugEnabled()){
LOG.debug("AUDIT PROPERTY: " + propNameObj.toString() + "="
+ props.getProperty(propNameObj.toString()));
}
}

// Process new audit configurations
Expand Down
4 changes: 3 additions & 1 deletion common/src/main/java/org/apache/atlas/service/Services.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.atlas.service;

import org.apache.atlas.annotation.AtlasService;
import org.apache.atlas.type.AtlasType;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
Expand All @@ -27,6 +28,7 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;

import java.util.List;

import static org.apache.atlas.AtlasConstants.ATLAS_MIGRATION_MODE_FILENAME;
Expand Down Expand Up @@ -65,8 +67,8 @@ public void start() {
continue;
}

LOG.info("Starting service {}", svc.getClass().getName());

LOG.info("Starting service {}", svc.getClass().getName());
svc.start();
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class GraphTransactionAdvisor extends AbstractPointcutAdvisor {
public boolean matches(Method method, Class<?> targetClass) {
boolean annotationPresent = method.isAnnotationPresent(GraphTransaction.class);
if (annotationPresent) {
LOG.info("GraphTransaction intercept for {}.{}", targetClass.getName(), method.getName());
if (LOG.isDebugEnabled()) {
LOG.debug("GraphTransaction intercept for {}.{}", targetClass.getName(), method.getName());
}
}
return annotationPresent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@ private void resolveIndexFieldName(AtlasGraphManagement managementSystem, AtlasA

typeRegistry.addIndexFieldName(attribute.getVertexPropertyName(), indexFieldName);

LOG.info("Property {} is mapped to index field name {}", attribute.getQualifiedName(), attribute.getIndexFieldName());
if (LOG.isDebugEnabled()){
LOG.debug("Property {} is mapped to index field name {}", attribute.getQualifiedName(), attribute.getIndexFieldName());
}
} else {
LOG.warn("resolveIndexFieldName(attribute={}): propertyKey is null for vertextPropertyName={}", attribute.getQualifiedName(), attribute.getVertexPropertyName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public class DTORegistry {
@Inject
public DTORegistry(Set<DataTransferObject> availableDTOs) {
for (DataTransferObject availableDTO : availableDTOs) {
LOG.info("Registering DTO: {}", availableDTO.getClass().getSimpleName());
if (LOG.isDebugEnabled()){
LOG.debug("Registering DTO: {}", availableDTO.getClass().getSimpleName());
}
registerDTO(availableDTO);
}
}
Expand Down

0 comments on commit 91041df

Please sign in to comment.