Search in sources :

Example 1 with RangerPolicyEngineOptions

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;
}
Also used : VXString(org.apache.ranger.view.VXString) RangerPolicyEngineOptions(org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions)

Example 2 with RangerPolicyEngineOptions

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...");
}
Also used : ArrayList(java.util.ArrayList) URL(java.net.URL) RangerPolicyEngineOptions(org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions)

Example 3 with RangerPolicyEngineOptions

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;
}
Also used : RangerPolicyEngineOptions(org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions)

Example 4 with RangerPolicyEngineOptions

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;
}
Also used : VXString(org.apache.ranger.view.VXString) RangerPolicyEngineOptions(org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions)

Example 5 with RangerPolicyEngineOptions

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;
}
Also used : VXString(org.apache.ranger.view.VXString) RangerPolicyEngineOptions(org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions)

Aggregations

RangerPolicyEngineOptions (org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions)6 VXString (org.apache.ranger.view.VXString)3 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 TestData (org.apache.ranger.authorization.hbase.TestPolicyEngine.PolicyEngineTestCase.TestData)1 RangerDefaultAuditHandler (org.apache.ranger.plugin.audit.RangerDefaultAuditHandler)1 RangerAccessRequest (org.apache.ranger.plugin.policyengine.RangerAccessRequest)1 RangerAccessResult (org.apache.ranger.plugin.policyengine.RangerAccessResult)1 RangerAccessResultProcessor (org.apache.ranger.plugin.policyengine.RangerAccessResultProcessor)1 RangerPolicyEngine (org.apache.ranger.plugin.policyengine.RangerPolicyEngine)1 RangerPolicyEngineImpl (org.apache.ranger.plugin.policyengine.RangerPolicyEngineImpl)1 ServicePolicies (org.apache.ranger.plugin.util.ServicePolicies)1