Package io.airlift.bootstrap

Examples of io.airlift.bootstrap.Bootstrap


            modules.add(new TestingDiscoveryModule());
        }

        modules.addAll(additionalModules);

        Bootstrap app = new Bootstrap(modules.build());

        Map<String, String> optionalProperties = new HashMap<>();
        if (environment != null) {
            optionalProperties.put("node.environment", environment);
        }

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(serverProperties.build())
                .setOptionalConfigurationProperties(optionalProperties)
                .initialize();
View Full Code Here


    @BeforeMethod
    public void setup()
            throws Exception
    {
        Bootstrap app = new Bootstrap(
                new TestingNodeModule(),
                new InMemoryEventModule(),
                new TestingHttpServerModule(),
                new JsonModule(),
                new JaxrsModule(),
                new Module()
                {
                    @Override
                    public void configure(Binder binder)
                    {
                        binder.bind(QueryResource.class).in(Scopes.SINGLETON);
                        binder.bind(StageResource.class).in(Scopes.SINGLETON);
                        binder.bind(TaskResource.class).in(Scopes.SINGLETON);
                        binder.bind(QueryManager.class).to(MockQueryManager.class).in(Scopes.SINGLETON);
                        binder.bind(MockTaskManager.class).in(Scopes.SINGLETON);
                        binder.bind(TaskManager.class).to(Key.get(MockTaskManager.class)).in(Scopes.SINGLETON);
                        binder.bind(PagesMapper.class).in(Scopes.SINGLETON);
                        binder.bind(InternalNodeManager.class).to(InMemoryNodeManager.class).in(Scopes.SINGLETON);
                        binder.bind(NodeManager.class).to(Key.get(InternalNodeManager.class)).in(Scopes.SINGLETON);
                        binder.bind(LocationFactory.class).to(HttpLocationFactory.class).in(Scopes.SINGLETON);
                    }
                });

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .initialize();

        lifeCycleManager = injector.getInstance(LifeCycleManager.class);
View Full Code Here

    @Test
    public void testGuiceInjection()
        throws Exception
    {
        Bootstrap bootstrap = new Bootstrap(new Module() {

            @Override
            public void configure(Binder binder)
            {
                bindConfig(binder).to(ThriftClientConfig.class);
            }
        });

        Map<String, String> properties = ImmutableMap.of();

        Injector injector = bootstrap.doNotInitializeLogging()
                        .strictConfig()
                        .setRequiredConfigurationProperties(properties)
                        .initialize();

        ThriftClientConfig clientConfig = injector.getInstance(ThriftClientConfig.class);
View Full Code Here

    @Test
    public void testGuiceInjection()
            throws Exception
    {
        Bootstrap bootstrap = new Bootstrap(new AbstractModule() {
            @Override
            protected void configure()
            {
                bindConfig(binder()).to(ThriftServerConfig.class);
            }
        });

        Map<String, String> properties = ImmutableMap.of();

        Injector injector =
                bootstrap.doNotInitializeLogging()
                .strictConfig()
                .setRequiredConfigurationProperties(properties)
                .initialize();

        ThriftServerConfig config = injector.getInstance(ThriftServerConfig.class);
View Full Code Here

    public void testWorkerThreadsConfiguration()
            throws Exception
    {
        final int WORKER_THREAD_COUNT = 43;

        Bootstrap bootstrap = new Bootstrap(
                new ThriftCodecModule(),
                new ThriftServerModule(),
                new AbstractModule()
                {
                    @Override
                    protected void configure()
                    {
                        bind(ExampleService.class);
                        thriftServerBinder(binder()).exportThriftService(ExampleService.class);
                    }
                }
        );

        Map<String, String> properties = ImmutableMap.of(
                "thrift.threads.max", Integer.toString(WORKER_THREAD_COUNT)
        );

        Injector injector =
                bootstrap.doNotInitializeLogging()
                         .strictConfig()
                         .setRequiredConfigurationProperties(properties)
                         .initialize();

        ThriftServer server = injector.getInstance(ThriftServer.class);
View Full Code Here

            throws Exception
    {
        final int WORKER_THREAD_COUNT = 43;
        final ExecutorService myExecutor = Executors.newFixedThreadPool(WORKER_THREAD_COUNT);

        Bootstrap bootstrap = new Bootstrap(
                new ThriftCodecModule(),
                overrideThriftServerModuleWithWorkerExecutorInstance(myExecutor),
                new AbstractModule()
                {
                    @Override
                    protected void configure()
                    {
                        bind(ExampleService.class);
                        thriftServerBinder(binder()).exportThriftService(ExampleService.class);
                    }
                }
        );

        Map<String, String> properties = ImmutableMap.of();

        Injector injector =
                bootstrap.doNotInitializeLogging()
                         .strictConfig()
                         .setRequiredConfigurationProperties(properties)
                         .initialize();

        ThriftServer server = injector.getInstance(ThriftServer.class);
View Full Code Here

            throws Exception
    {
        final int WORKER_THREAD_COUNT = 44;
        final ExecutorService myExecutor = Executors.newFixedThreadPool(WORKER_THREAD_COUNT);

        Bootstrap bootstrap = new Bootstrap(
                new ThriftCodecModule(),
                new ThriftServerModule(),
                new AbstractModule()
                {
                    @Override
                    protected void configure()
                    {
                        bind(ExampleService.class);

                        bindWorkerExecutor(binder(), "my-executor", myExecutor);
                        thriftServerBinder(binder()).exportThriftService(ExampleService.class);
                    }
                }
        );

        Map<String, String> properties = ImmutableMap.of(
                "thrift.worker-executor-key", "my-executor"
        );

        Injector injector =
                bootstrap.doNotInitializeLogging()
                         .strictConfig()
                         .setRequiredConfigurationProperties(properties)
                         .initialize();

        ThriftServer server = injector.getInstance(ThriftServer.class);
View Full Code Here

        Map<String, String> serverProperties = ImmutableMap.<String, String>builder()
                .put("static.db.location", tempDir.getAbsolutePath())
                .build();

        Bootstrap app = new Bootstrap(
                new MBeanModule(),
                new TestingNodeModule(environment),
                new TestingHttpServerModule(),
                new JsonModule(),
                new JaxrsModule(true),
                new DiscoveryServerModule(),
                new DiscoveryModule(),
                new TestingJmxModule());

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(serverProperties)
                .initialize();
View Full Code Here

            modules.add(new TestingDiscoveryModule());
        }

        modules.addAll(additionalModules);

        Bootstrap app = new Bootstrap(modules.build());

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(serverProperties.build())
                .initialize();
View Full Code Here

    {
        checkNotNull(requiredConfig, "requiredConfig is null");
        checkNotNull(optionalConfig, "optionalConfig is null");

        try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
            Bootstrap app = new Bootstrap(new JdbcModule(connectorId), module);

            Injector injector = app
                    .strictConfig()
                    .doNotInitializeLogging()
                    .setRequiredConfigurationProperties(requiredConfig)
                    .setOptionalConfigurationProperties(optionalConfig)
                    .initialize();
View Full Code Here

TOP

Related Classes of io.airlift.bootstrap.Bootstrap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.