Examples of Bootstrap


Examples of io.airlift.bootstrap.Bootstrap

        final String port = Integer.toString(NetUtils.findUnusedPort());

        final Map<String, String> properties = ImmutableMap.of("hive-metastore.port", port,
                                                               "thrift.port", port);

        final Injector inj = new Bootstrap(new DummyHiveMetastoreServerModule(),
                                           new HiveMetastoreClientModule(),
                                           new ThriftClientModule(),
                                           new ThriftCodecModule())
            .setRequiredConfigurationProperties(properties)
            .strictConfig()
View Full Code Here

Examples of io.airlift.bootstrap.Bootstrap

        final Map<String, String> properties = ImmutableMap.of(
            "hive-metastore.port", port,
            "hive-metastore.max-retries", "0");

        final Injector inj = new Bootstrap(new HiveMetastoreClientModule(),
                                           new ThriftClientModule(),
                                           new ThriftCodecModule())
            .setRequiredConfigurationProperties(properties)
            .strictConfig()
            .initialize();

        inj.injectMembers(this);

        try (HiveMetastore metastore = metastoreProvider.get()) {
            assertFalse(metastore.isConnected());
        }

        final Map<String, String> serverProps = ImmutableMap.of("thrift.port", port);

        new Bootstrap(new DummyHiveMetastoreServerModule(),
                      new HiveMetastoreClientModule(),
                      new ThriftClientModule(),
                      new ThriftCodecModule())
            .setRequiredConfigurationProperties(serverProps)
            .strictConfig()
View Full Code Here

Examples of io.airlift.bootstrap.Bootstrap

    private void startService(int port) throws Exception
    {
        final Map<String, String> properties = ImmutableMap.of("thrift.port", Integer.toString(port));

        final Injector inj = new Bootstrap(new DummyHiveMetastoreServerModule(),
                                           new ThriftCodecModule())
            .setRequiredConfigurationProperties(properties)
            .doNotInitializeLogging()
            .strictConfig()
            .initialize();
View Full Code Here

Examples of io.airlift.bootstrap.Bootstrap

    private void startService(int port) throws Exception
    {
        final Map<String, String> properties = ImmutableMap.of("thrift.port", Integer.toString(port));

        final Injector inj = new Bootstrap(new DummyHiveMetastoreServerModule(),
                                           new ThriftCodecModule())
            .setRequiredConfigurationProperties(properties)
            .doNotInitializeLogging()
            .strictConfig()
            .initialize();
View Full Code Here

Examples of io.airlift.bootstrap.Bootstrap

    public Connector create(String connectorId, Map<String, String> config)
    {
        checkNotNull(config, "config is null");

        try {
            Bootstrap app = new Bootstrap(
                    new MBeanModule(),
                    new JsonModule(),
                    new CassandraClientModule(connectorId),
                    new Module()
                    {
                        @Override
                        public void configure(Binder binder)
                        {
                            MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
                            binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(platformMBeanServer));
                        }
                    });

            Injector injector = app.strictConfig().doNotInitializeLogging()
                    .setRequiredConfigurationProperties(config)
                    .setOptionalConfigurationProperties(optionalConfig).initialize();

            return injector.getInstance(CassandraConnector.class);
        }
View Full Code Here

Examples of io.airlift.bootstrap.Bootstrap

    @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(PagesResponseWriter.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

Examples of io.airlift.bootstrap.Bootstrap

    public Connector create(String connectorId, Map<String, String> config)
    {
        checkNotNull(config, "config is null");

        try {
            Bootstrap app = new Bootstrap(
                    new NodeModule(),
                    new MBeanModule(),
                    new JsonModule(),
                    new CassandraClientModule(connectorId),
                    new Module()
                    {
                        @Override
                        public void configure(Binder binder)
                        {
                            MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
                            binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(platformMBeanServer));
                        }
                    });

            Injector injector = app.strictConfig().doNotInitializeLogging()
                    .setRequiredConfigurationProperties(config)
                    .setOptionalConfigurationProperties(optionalConfig).initialize();

            CassandraMetadata metadata = injector.getInstance(CassandraMetadata.class);
            CassandraSplitManager splitManager = injector.getInstance(CassandraSplitManager.class);
View Full Code Here

Examples of io.fletty.bootstrap.Bootstrap

        }
        channel.writeAndFlush(data + "\n");
    }

    protected void _connect(String host, int port) {
        Bootstrap b = new Bootstrap();

        if (!context.addGroup(b)) {
            Flog.warn("no loopgroup, will not reconnect");
            return;
        }
        b.channel(NioSocketChannel.class);
        b.option(ChannelOption.SO_KEEPALIVE, true);
        b.option(ChannelOption.TCP_NODELAY, true);
        b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 15*1000);
        b.handler(new FlooChannelInitializer(this));

        try {
            ChannelFuture connect = b.connect(host, port);
            channel = connect.channel();
        }   catch (RejectedExecutionException e) {
            context.errorMessage("Can not connect to floobits!");
            context.shutdown();
        }   catch (Throwable e) {
View Full Code Here

Examples of io.netty.bootstrap.Bootstrap

    if (this.connectFuture != null) {
      throw new IllegalStateException(String.format("%s already started a connection attempt.", this.name));
    }

    final Bootstrap bootstrap = new Bootstrap();
    bootstrap.group(this.eventLoopGroup);
    bootstrap.channel(NioSocketChannel.class);
    bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);

    // TODO Remove this when Netty 5 is available
    bootstrap.option(ChannelOption.AUTO_CLOSE, false);

    bootstrap.handler(new ChannelInitializer<SocketChannel>() {

      @Override
      protected void initChannel(final SocketChannel channel) {
        final ChannelPipeline pipeline = channel.pipeline();

        final SSLEngine sslEngine = apnsConnection.sslContext.createSSLEngine();
        sslEngine.setUseClientMode(true);

        pipeline.addLast("ssl", new SslHandler(sslEngine));
        pipeline.addLast("decoder", new RejectedNotificationDecoder());
        pipeline.addLast("encoder", new ApnsPushNotificationEncoder());
        pipeline.addLast(ApnsConnection.PIPELINE_MAIN_HANDLER, new ApnsConnectionHandler(apnsConnection));
      }
    });

    log.debug("{} beginning connection process.", apnsConnection.name);
    this.connectFuture = bootstrap.connect(this.environment.getApnsGatewayHost(), this.environment.getApnsGatewayPort());
    this.connectFuture.addListener(new GenericFutureListener<ChannelFuture>() {

      @Override
      public void operationComplete(final ChannelFuture connectFuture) {
        if (connectFuture.isSuccess()) {
View Full Code Here

Examples of io.netty.bootstrap.Bootstrap

    if (this.connectFuture != null) {
      throw new IllegalStateException(String.format("%s already started a connection attempt.", this.name));
    }

    final Bootstrap bootstrap = new Bootstrap();
    bootstrap.group(this.eventLoopGroup);
    bootstrap.channel(NioSocketChannel.class);

    final FeedbackServiceConnection feedbackConnection = this;
    bootstrap.handler(new ChannelInitializer<SocketChannel>() {

      @Override
      protected void initChannel(final SocketChannel channel) throws Exception {
        final ChannelPipeline pipeline = channel.pipeline();

        final SSLEngine sslEngine = feedbackConnection.sslContext.createSSLEngine();
        sslEngine.setUseClientMode(true);

        pipeline.addLast("ssl", new SslHandler(sslEngine));
        pipeline.addLast("readTimeoutHandler", new ReadTimeoutHandler(feedbackConnection.configuration.getReadTimeout()));
        pipeline.addLast("decoder", new ExpiredTokenDecoder());
        pipeline.addLast("handler", new FeedbackClientHandler(feedbackConnection));
      }
    });

    this.connectFuture = bootstrap.connect(this.environment.getFeedbackHost(), this.environment.getFeedbackPort());
    this.connectFuture.addListener(new GenericFutureListener<ChannelFuture>() {

      @Override
      public void operationComplete(final ChannelFuture connectFuture) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.