Search in sources :

Example 31 with GatewayConfigImpl

use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.

the class KnoxCLITest method testDeleteOfNonExistAliasFromDefaultCluster.

@Test
public void testDeleteOfNonExistAliasFromDefaultCluster() throws Exception {
    KnoxCLI cli = new KnoxCLI();
    cli.setConf(new GatewayConfigImpl());
    try {
        int rc = 0;
        outContent.reset();
        String[] args1 = { "create-alias", "alias1", "--value", "testvalue1", "--master", "master" };
        cli.run(args1);
        // Delete invalid alias from the cluster
        outContent.reset();
        String[] args2 = { "delete-alias", "alias2", "--master", "master" };
        rc = cli.run(args2);
        assertEquals(0, rc);
        assertTrue(outContent.toString().contains("No such alias exists in the cluster."));
    } finally {
        outContent.reset();
        String[] args1 = { "delete-alias", "alias1", "--master", "master" };
        cli.run(args1);
    }
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) Test(org.junit.Test)

Example 32 with GatewayConfigImpl

use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.

the class GatewayServer method main.

public static void main(String[] args) {
    try {
        configureLogging();
        logSysProps();
        CommandLine cmd = GatewayCommandLine.parse(args);
        if (cmd.hasOption(GatewayCommandLine.HELP_LONG)) {
            GatewayCommandLine.printHelp();
        } else if (cmd.hasOption(GatewayCommandLine.VERSION_LONG)) {
            printVersion();
        } else if (cmd.hasOption(GatewayCommandLine.REDEPLOY_LONG)) {
            redeployTopologies(cmd.getOptionValue(GatewayCommandLine.REDEPLOY_LONG));
        } else {
            buildProperties = loadBuildProperties();
            services = instantiateGatewayServices();
            if (services == null) {
                log.failedToInstantiateGatewayServices();
            }
            GatewayConfig config = new GatewayConfigImpl();
            if (config.isHadoopKerberosSecured()) {
                configureKerberosSecurity(config);
            }
            Map<String, String> options = new HashMap<>();
            options.put(GatewayCommandLine.PERSIST_LONG, Boolean.toString(cmd.hasOption(GatewayCommandLine.PERSIST_LONG)));
            services.init(config, options);
            if (!cmd.hasOption(GatewayCommandLine.NOSTART_LONG)) {
                startGateway(config, services);
            }
        }
    } catch (ParseException e) {
        log.failedToParseCommandLine(e);
        GatewayCommandLine.printHelp();
    } catch (Exception e) {
        log.failedToStartGateway(e);
        // Make sure the process exits.
        System.exit(1);
    }
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ParseException(org.apache.commons.cli.ParseException) GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) DeploymentException(org.apache.knox.gateway.deploy.DeploymentException) URISyntaxException(java.net.URISyntaxException) KeyStoreException(java.security.KeyStoreException) ZipException(net.lingala.zip4j.exception.ZipException) ParseException(org.apache.commons.cli.ParseException) SAXException(org.xml.sax.SAXException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) UnknownHostException(java.net.UnknownHostException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) GatewayConfig(org.apache.knox.gateway.config.GatewayConfig)

Example 33 with GatewayConfigImpl

use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.

the class KnoxCLI method getGatewayConfig.

private GatewayConfig getGatewayConfig() {
    GatewayConfig result;
    Configuration conf = getConf();
    if (conf != null && conf instanceof GatewayConfig) {
        result = (GatewayConfig) conf;
    } else {
        result = new GatewayConfigImpl();
    }
    return result;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) GatewayConfig(org.apache.knox.gateway.config.GatewayConfig)

Example 34 with GatewayConfigImpl

use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.

the class KnoxCLI method main.

/**
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    PropertyConfigurator.configure(System.getProperty("log4j.configuration"));
    int res = ToolRunner.run(new GatewayConfigImpl(), new KnoxCLI(), args);
    System.exit(res);
}
Also used : GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl)

Example 35 with GatewayConfigImpl

use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.

the class DefaultMetricsServiceTest method lifecycle.

@Test
public void lifecycle() throws Exception {
    DefaultMetricsService service = new DefaultMetricsService();
    service.init(new GatewayConfigImpl(), null);
    Assert.assertNotNull(service.getContext());
    Assert.assertNotNull(service.getMetricRegistry());
    Assert.assertNotNull(service.getMetricsReporters());
    Assert.assertNotNull(service.getInstrumentationProviders());
    service.start();
    Assert.assertNotNull(service.getContext().getMetricsService());
    MetricRegistry metricRegistry = (MetricRegistry) service.getContext().getProperty(DefaultMetricsService.METRICS_REGISTRY);
    Assert.assertNotNull(metricRegistry);
    service.stop();
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) Test(org.junit.Test)

Aggregations

GatewayConfigImpl (org.apache.knox.gateway.config.impl.GatewayConfigImpl)45 Test (org.junit.Test)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 GatewayConfig (org.apache.knox.gateway.config.GatewayConfig)19 File (java.io.File)13 Configuration (org.apache.hadoop.conf.Configuration)10 MasterService (org.apache.knox.gateway.services.security.MasterService)3 HttpClientBuilder (org.apache.http.impl.client.HttpClientBuilder)2 InstrumentationProvider (org.apache.knox.gateway.services.metrics.InstrumentationProvider)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1