Skip to content

Commit

Permalink
Merge branch 'master' into origin/master/013_unused_deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mneethiraj authored Aug 2, 2024
2 parents c650d89 + f1c8f00 commit e8bf9ef
Show file tree
Hide file tree
Showing 53 changed files with 2,099 additions and 929 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public synchronized void init(Properties props, String appType) {
mProvider.start();
}

installJvmSutdownHook(props);
installJvmShutdownHook(props);
}

private AuditHandler getProviderFromConfig(Properties props,
Expand Down Expand Up @@ -474,7 +474,7 @@ private AuditHandler getDefaultProvider() {
return new DummyAuditProvider();
}

private void installJvmSutdownHook(Properties props) {
private void installJvmShutdownHook(Properties props) {
int shutdownHookMaxWaitSeconds = MiscUtil.getIntProperty(props, AUDIT_SHUTDOWN_HOOK_MAX_WAIT_SEC, AUDIT_SHUTDOWN_HOOK_MAX_WAIT_SEC_DEFAULT);
jvmShutdownHook = new JVMShutdownHook(mProvider, shutdownHookMaxWaitSeconds);
String appType = this.componentAppType;
Expand Down Expand Up @@ -502,7 +502,7 @@ public void run() {
try {
startCleanup.acquire();
} catch (InterruptedException e) {
LOG.info("RangerAsyncAuditCleanup: Interrupted while waiting for audit startCleanup signal! Exiting the thread...", e);
LOG.error("RangerAsyncAuditCleanup: Interrupted while waiting for audit startCleanup signal! Exiting the thread...", e);
break;
}
LOG.info("RangerAsyncAuditCleanup: Starting cleanup");
Expand Down Expand Up @@ -547,7 +547,7 @@ public void run() {
LOG.warn("JVMShutdownHook: could not detect finishing of audit cleanup even after waiting for " + maxWait + " seconds!");
}
} catch (InterruptedException e) {
LOG.info("JVMShutdownHook: Interrupted while waiting for completion of Async executor!", e);
LOG.error("JVMShutdownHook: Interrupted while waiting for completion of Async executor!", e);
}
LOG.info("JVMShutdownHook: Interrupting ranger async audit cleanup thread");
cleanupThread.interrupt();
Expand Down
12 changes: 12 additions & 0 deletions agents-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>${jersey-bundle.version}</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand Down Expand Up @@ -125,6 +131,12 @@
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${fasterxml.jackson.version}</version>
<exclusions>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* 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.ranger.plugin.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@JsonInclude(Include.NON_EMPTY)
public class RangerServerHealth {
public enum RangerServerStatus {
UNKNOWN, INITIALIZING, INITIALIZATION_FAILURE, UP, DOWN
}

private final RangerServerStatus status;
private final Map<String, Object> details;

private RangerServerHealth(Builder builder) {
this.status = builder.status;
this.details = Collections.unmodifiableMap(builder.details);
}

public RangerServerStatus getStatus() {
return this.status;
}

public Map<String, Object> getDetails() {
return this.details;
}

public static Builder unknown() {
return status(RangerServerStatus.UNKNOWN);
}

public static Builder up() {
return status(RangerServerStatus.UP);
}

public static Builder down() {
return status(RangerServerStatus.DOWN);
}

public static Builder status(RangerServerStatus status) {
return new Builder(status);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (!(o instanceof RangerServerHealth)) {
return false;
}

RangerServerHealth health = (RangerServerHealth) o;

return Objects.equals(status, health.status) && Objects.equals(details, health.details);
}

@Override
public int hashCode() {
return Objects.hash(status, details);
}

@Override
public String toString() {
return getStatus() + " " + getDetails();
}

public static class Builder {
private RangerServerStatus status;
private final Map<String, Object> details;

public Builder() {
this.status = RangerServerStatus.UNKNOWN;
this.details = new LinkedHashMap<>();
}

public Builder(RangerServerStatus status) {
this.status = status;
this.details = new LinkedHashMap<>();
}

public Builder(RangerServerStatus status, Map<String, ?> details) {
this.status = status;
this.details = new LinkedHashMap<>(details);
}

public Builder withDetail(String key, Object value) {
this.details.put(key, value);
return this;
}

public RangerServerHealth build() {
return new RangerServerHealth(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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.ranger.plugin.model;

import static org.apache.ranger.plugin.model.RangerServerHealth.RangerServerStatus.*;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;

public class TestRangerHealth {
@Test
public void testRangerStatusUP() {
Map<String, Object> componentsMap = new HashMap<>();
Map<String, Object> dbMap = new LinkedHashMap<>();
dbMap.put("status", UP);
Map<String, Object> dbDetailsMap = new LinkedHashMap<>();
dbDetailsMap.put("database","Oracle 21.3c");
dbDetailsMap.put("validationQuery","SELECT banner from v$version where rownum<2");
dbMap.put("details",dbDetailsMap);
componentsMap.put("db",dbMap);
Map<String, Object> auditProviderMap = new LinkedHashMap<>();
auditProviderMap.put("status", UP);
Map<String, Object> auditProviderDetailsMap = new LinkedHashMap<>();
auditProviderDetailsMap.put("provider","Elastic Search");
auditProviderDetailsMap.put("providerHealthCheckEndpoint","http://localhost:9200/_cluster/health?pretty");
auditProviderDetailsMap.put("details", auditProviderDetailsMap);
componentsMap.put("auditProvider",auditProviderMap);
RangerServerHealth rangerHealth = RangerServerHealth.up().withDetail("components", componentsMap).build();
Assert.assertEquals("RangerHealth.up()", UP, rangerHealth.getStatus());
Assert.assertEquals("RangerHealth.getDetails()", 1, rangerHealth.getDetails().size());
Assert.assertEquals("RangerHealth.getDetails('component')", 2, ((Map<?, ?>) rangerHealth.getDetails().get("components")).size());
}

@Test
public void testRangerStatusDOWN() {
Map<String, Object> componentsMap = new HashMap<>();
Map<String, Object> dbMap = new LinkedHashMap<>();
dbMap.put("status", DOWN);
Map<String, Object> dbDetailsMap = new LinkedHashMap<>();
dbDetailsMap.put("database","Oracle 21.3c");
dbDetailsMap.put("validationQuery","SELECT banner from v$version where rownum<2");
dbMap.put("details",dbDetailsMap);
componentsMap.put("db",dbMap);
Map<String, Object> auditProviderMap = new LinkedHashMap<>();
auditProviderMap.put("status", DOWN);
Map<String, Object> auditProviderDetailsMap = new LinkedHashMap<>();
auditProviderDetailsMap.put("provider","Elastic Search");
auditProviderDetailsMap.put("providerHealthCheckEndpoint","http://localhost:9200/_cluster/health?pretty");
auditProviderDetailsMap.put("details", auditProviderDetailsMap);
componentsMap.put("auditProvider",auditProviderMap);
RangerServerHealth rangerHealth = RangerServerHealth.down().withDetail("components", componentsMap).build();
Assert.assertEquals("RangerHealth.down()", DOWN, rangerHealth.getStatus());
Assert.assertEquals("RangerHealth.getDetails()", 1, rangerHealth.getDetails().size());
Assert.assertEquals("RangerHealth.getDetails('component')", 2, ((Map<?, ?>) rangerHealth.getDetails().get("components")).size());
}
}
4 changes: 2 additions & 2 deletions dev-support/ranger-docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ UBUNTU_VERSION=20.04
MARIADB_VERSION=10.7.3
POSTGRES_VERSION=12
ENABLE_DB_MOUNT=true
ZK_VERSION=3.5.9
ZK_VERSION=3.9.2
SOLR_VERSION=8.11.3

# service versions
HADOOP_VERSION=3.3.3
HADOOP_VERSION=3.3.4
HBASE_VERSION=2.6.0
HIVE_VERSION=3.1.3
HIVE_HADOOP_VERSION=3.1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class EmbeddedServer {
private static final String ADMIN_NAME_RULES = "hadoop.security.auth_to_local";
private static final String ADMIN_SERVER_NAME = "rangeradmin";
private static final String KMS_SERVER_NAME = "rangerkms";
private static final String ACCESS_LOG_ENABLED = "ranger.accesslog.enabled";
private static final String ACCESS_LOG_PREFIX = "ranger.accesslog.prefix";
private static final String ACCESS_LOG_DATE_FORMAT = "ranger.accesslog.dateformat";
private static final String ACCESS_LOG_PATTERN = "ranger.accesslog.pattern";
Expand All @@ -87,6 +88,7 @@ public class EmbeddedServer {
public static final String RANGER_SSL_KEYMANAGER_ALGO_TYPE = KeyManagerFactory.getDefaultAlgorithm();
public static final String RANGER_SSL_TRUSTMANAGER_ALGO_TYPE = TrustManagerFactory.getDefaultAlgorithm();


private static EmbeddedServerMetricsCollector serverMetricsCollector;

public static void main(String[] args) {
Expand Down Expand Up @@ -196,7 +198,7 @@ public void start() {
valve.setRotatable(true);
valve.setAsyncSupported(true);
valve.setBuffered(false);
valve.setEnabled(true);
valve.setEnabled(EmbeddedServerUtil.getBooleanConfig(ACCESS_LOG_ENABLED, true));
valve.setPrefix(EmbeddedServerUtil.getConfig(ACCESS_LOG_PREFIX,"access-" + hostName));
valve.setFileDateFormat(EmbeddedServerUtil.getConfig(ACCESS_LOG_DATE_FORMAT, "-yyyy-MM-dd.HH"));
valve.setDirectory(logDirectory.getAbsolutePath());
Expand Down
24 changes: 24 additions & 0 deletions hbase-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -117,12 +121,24 @@
<artifactId>jersey-client</artifactId>
<type>jar</type>
<version>${jersey-bundle.version}</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<type>jar</type>
<version>${jersey-bundle.version}</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ranger</groupId>
Expand Down Expand Up @@ -267,6 +283,10 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -355,6 +375,10 @@
<groupId>log4j</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
4 changes: 4 additions & 0 deletions hdfs-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Loading

0 comments on commit e8bf9ef

Please sign in to comment.