use of org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions in project ranger by apache.
the class ServiceREST method getPolicySearchRangerAdminPolicyEngineOptions.
private RangerPolicyEngineOptions getPolicySearchRangerAdminPolicyEngineOptions() {
RangerPolicyEngineOptions opts = new RangerPolicyEngineOptions();
final String propertyPrefix = "ranger.admin";
opts.configureRangerAdminForPolicySearch(RangerConfiguration.getInstance(), propertyPrefix);
return opts;
}
use of org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions in project ranger by apache.
the class RangerPolicyenginePerfTester method main.
public static void main(String[] args) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> RangerPolicyenginePerfTester.main()");
}
CommandLineParser commandLineParser = new CommandLineParser();
PerfTestOptions perfTestOptions = commandLineParser.parse(args);
if (perfTestOptions != null) {
URL statCollectionFileURL = perfTestOptions.getStatCollectionFileURL();
List<String> perfModuleNames = statCollectionFileURL != null ? buildPerfModuleNames(statCollectionFileURL) : new ArrayList<String>();
PerfDataRecorder.initialize(perfModuleNames);
URL servicePoliciesFileURL = perfTestOptions.getServicePoliciesFileURL();
RangerPolicyEngineOptions policyEngineOptions = new RangerPolicyEngineOptions();
policyEngineOptions.disableTagPolicyEvaluation = false;
policyEngineOptions.evaluatorType = RangerPolicyEvaluator.EVALUATOR_TYPE_OPTIMIZED;
policyEngineOptions.cacheAuditResults = false;
policyEngineOptions.disableTrieLookupPrefilter = perfTestOptions.getIsTrieLookupPrefixDisabled();
PerfTestEngine perfTestEngine = new PerfTestEngine(servicePoliciesFileURL, policyEngineOptions, perfTestOptions.getIsDynamicReorderingDisabled());
if (!perfTestEngine.init()) {
LOG.error("Error initializing test data. Existing...");
System.exit(1);
}
URL[] requestFileURLs = perfTestOptions.getRequestFileURLs();
int requestFilesCount = requestFileURLs.length;
// warm-up policy engine
LOG.error("Warming up..");
try {
for (URL requestFileURL : requestFileURLs) {
PerfTestClient perfTestClient = new PerfTestClient(perfTestEngine, 0, requestFileURL, 1);
if (perfTestClient.init()) {
perfTestClient.start();
perfTestClient.join();
} else {
LOG.error("Error initializing warm-up PerfTestClient");
}
}
} catch (Throwable t) {
LOG.error("Error during warmup", t);
}
LOG.error("Warmed up!");
PerfDataRecorder.clearStatistics();
int clientsCount = perfTestOptions.getConcurrentClientCount();
List<PerfTestClient> perfTestClients = new ArrayList<PerfTestClient>(clientsCount);
for (int i = 0; i < clientsCount; i++) {
URL requestFileURL = requestFileURLs[i % requestFilesCount];
PerfTestClient perfTestClient = new PerfTestClient(perfTestEngine, i, requestFileURL, perfTestOptions.getIterationsCount());
if (!perfTestClient.init()) {
LOG.error("Error initializing PerfTestClient: (id=" + i + ")");
} else {
perfTestClients.add(perfTestClient);
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Number of perfTestClients=" + perfTestClients.size());
}
Runtime runtime = Runtime.getRuntime();
runtime.gc();
long totalMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
LOG.info("Memory stats: max-available=:" + runtime.maxMemory() + "; in-use=" + (totalMemory - freeMemory) + "; free=" + freeMemory);
LOG.info("Starting " + perfTestClients.size() + " clients..");
for (PerfTestClient client : perfTestClients) {
try {
client.start();
} catch (Throwable t) {
LOG.error("Error in starting client: " + client.getName(), t);
}
}
LOG.info("Started " + perfTestClients.size() + " clients");
LOG.info("Waiting for " + perfTestClients.size() + " clients to finish up");
for (PerfTestClient client : perfTestClients) {
while (client.isAlive()) {
try {
client.join(1000);
runtime.gc();
totalMemory = runtime.totalMemory();
freeMemory = runtime.freeMemory();
LOG.info("Memory stats: max-available=:" + runtime.maxMemory() + "; in-use=" + (totalMemory - freeMemory) + "; free=" + freeMemory);
} catch (InterruptedException interruptedException) {
LOG.error("PerfTestClient.join() was interrupted");
}
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== RangerPolicyenginePerfTester.main()");
}
LOG.info("Completed performance-run");
perfTestEngine.cleanup();
PerfDataRecorder.printStatistics();
}
LOG.info("Exiting...");
}
use of org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions in project ranger by apache.
the class RangerPolicyFactory method createPolicyEngineOption.
public static RangerPolicyEngineOptions createPolicyEngineOption() {
RangerPolicyEngineOptions policyEngineOptions = new RangerPolicyEngineOptions();
policyEngineOptions.disableTagPolicyEvaluation = false;
policyEngineOptions.evaluatorType = RangerPolicyEvaluator.EVALUATOR_TYPE_OPTIMIZED;
policyEngineOptions.cacheAuditResults = false;
policyEngineOptions.disableTrieLookupPrefilter = true;
return policyEngineOptions;
}
use of org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions in project ranger by apache.
the class ServiceREST method getDefaultRangerAdminPolicyEngineOptions.
private RangerPolicyEngineOptions getDefaultRangerAdminPolicyEngineOptions() {
RangerPolicyEngineOptions opts = new RangerPolicyEngineOptions();
final String propertyPrefix = "ranger.admin";
opts.configureDefaultRangerAdmin(RangerConfiguration.getInstance(), propertyPrefix);
return opts;
}
use of org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions in project ranger by apache.
the class ServiceREST method getDelegatedAdminPolicyEngineOptions.
private RangerPolicyEngineOptions getDelegatedAdminPolicyEngineOptions() {
RangerPolicyEngineOptions opts = new RangerPolicyEngineOptions();
final String propertyPrefix = "ranger.admin";
opts.configureDelegateAdmin(RangerConfiguration.getInstance(), propertyPrefix);
return opts;
}
Aggregations