Java Code Examples for org.apache.thrift.server.TThreadPoolServer#isServing()

The following examples show how to use org.apache.thrift.server.TThreadPoolServer#isServing() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected void init() throws Exception {
    TServerTransport serverTransport = new TServerSocket( PORT );

    TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

    server = new TThreadPoolServer(
            new TThreadPoolServer.Args( serverTransport )
                    .inputProtocolFactory( bFactory )
                    .outputProtocolFactory( bFactory )
                    .inputTransportFactory( getTransportFactory() )
                    .outputTransportFactory( getTransportFactory() )
                    .processor( getProcessor() ) );

    Thread startTread = new Thread() {

        @Override
        public void run() {
            server.serve();
        }

    };

    startTread.setName( "thrift-server" );

    startTread.start();

    while( !server.isServing() ) {
        Thread.sleep( 100 );
    }

    protocol = ExtensionLoader.getExtensionLoader(Protocol.class)
            .getExtension( ThriftProtocol.NAME );

    invoker = protocol.refer( getInterface(), getUrl() );

}
 
Example 2
Source File: AbstractTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
protected void init() throws Exception {
    TServerTransport serverTransport = new TServerSocket( PORT );

    TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

    server = new TThreadPoolServer(
            new TThreadPoolServer.Args( serverTransport )
                    .inputProtocolFactory( bFactory )
                    .outputProtocolFactory( bFactory )
                    .inputTransportFactory( getTransportFactory() )
                    .outputTransportFactory( getTransportFactory() )
                    .processor( getProcessor() ) );

    Thread startTread = new Thread() {

        @Override
        public void run() {
            server.serve();
        }

    };

    startTread.setName( "thrift-server" );

    startTread.start();

    while( !server.isServing() ) {
        Thread.sleep( 100 );
    }

    protocol = ExtensionLoader.getExtensionLoader(Protocol.class)
            .getExtension( ThriftProtocol.NAME );

    invoker = protocol.refer( getInterface(), getUrl() );

}
 
Example 3
Source File: AbstractTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected void init() throws Exception {
    TServerTransport serverTransport = new TServerSocket( PORT );

    TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

    server = new TThreadPoolServer(
            new TThreadPoolServer.Args( serverTransport )
                    .inputProtocolFactory( bFactory )
                    .outputProtocolFactory( bFactory )
                    .inputTransportFactory( getTransportFactory() )
                    .outputTransportFactory( getTransportFactory() )
                    .processor( getProcessor() ) );

    Thread startTread = new Thread() {

        @Override
        public void run() {
            server.serve();
        }

    };

    startTread.setName( "thrift-server" );

    startTread.start();

    while( !server.isServing() ) {
        Thread.sleep( 100 );
    }

    protocol = ExtensionLoader.getExtensionLoader(Protocol.class)
            .getExtension( ThriftProtocol.NAME );

    invoker = protocol.refer( getInterface(), getUrl() );

}
 
Example 4
Source File: AbstractTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected void init() throws Exception {
    TServerTransport serverTransport = new TServerSocket( PORT );

    TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

    server = new TThreadPoolServer(
            new TThreadPoolServer.Args( serverTransport )
                    .inputProtocolFactory( bFactory )
                    .outputProtocolFactory( bFactory )
                    .inputTransportFactory( getTransportFactory() )
                    .outputTransportFactory( getTransportFactory() )
                    .processor( getProcessor() ) );

    Thread startTread = new Thread() {

        @Override
        public void run() {
            server.serve();
        }

    };

    startTread.setName( "thrift-server" );

    startTread.start();

    while( !server.isServing() ) {
        Thread.sleep( 100 );
    }

    protocol = ExtensionLoader.getExtensionLoader(Protocol.class)
            .getExtension( ThriftProtocol.NAME );

    invoker = protocol.refer( getInterface(), getUrl() );

}
 
Example 5
Source File: AbstractTest.java    From dubbo-2.6.5 with Apache License 2.0 3 votes vote down vote up
protected void init() throws Exception {

        serverTransport = new TServerSocket(PORT);

        TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

        server = new TThreadPoolServer(
                new TThreadPoolServer.Args(serverTransport)
                        .inputProtocolFactory(bFactory)
                        .outputProtocolFactory(bFactory)
                        .inputTransportFactory(getTransportFactory())
                        .outputTransportFactory(getTransportFactory())
                        .processor(getProcessor()));

        Thread startTread = new Thread() {

            @Override
            public void run() {
                server.serve();
            }

        };

        startTread.setName("thrift-server");

        startTread.start();

        while (!server.isServing()) {
            Thread.sleep(100);
        }

        protocol = ExtensionLoader.getExtensionLoader(Protocol.class)
                .getExtension(ThriftProtocol.NAME);

        invoker = protocol.refer(getInterface(), getUrl());

    }
 
Example 6
Source File: ServiceMethodNotFoundTest.java    From dubbo-2.6.5 with Apache License 2.0 2 votes vote down vote up
protected void init() throws Exception {

        TServerTransport serverTransport = new TServerSocket(PORT);

        DubboDemoImpl impl = new DubboDemoImpl();

        $__DemoStub.Processor processor = new $__DemoStub.Processor(impl);

        // for test
        Field field = processor.getClass().getSuperclass().getDeclaredField("processMap");

        field.setAccessible(true);

        Object obj = field.get(processor);

        if (obj instanceof Map) {
            ((Map) obj).remove("echoString");
        }
        // ~

        TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

        MultiServiceProcessor wrapper = new MultiServiceProcessor();
        wrapper.addProcessor(Demo.class, processor);

        server = new TThreadPoolServer(
                new TThreadPoolServer.Args(serverTransport)
                        .inputProtocolFactory(bFactory)
                        .outputProtocolFactory(bFactory)
                        .inputTransportFactory(getTransportFactory())
                        .outputTransportFactory(getTransportFactory())
                        .processor(wrapper));

        Thread startTread = new Thread() {

            @Override
            public void run() {

                server.serve();
            }

        };

        startTread.start();

        while (!server.isServing()) {
            Thread.sleep(100);
        }

    }
 
Example 7
Source File: ServiceMethodNotFoundTest.java    From dubbox with Apache License 2.0 2 votes vote down vote up
protected void init() throws Exception {

        TServerTransport serverTransport = new TServerSocket( PORT );

        DubboDemoImpl impl = new DubboDemoImpl();

        $__DemoStub.Processor processor = new $__DemoStub.Processor( impl );

        // for test
        Field field = processor.getClass().getSuperclass().getDeclaredField( "processMap" );

        field.setAccessible( true );

        Object obj = field.get( processor );

        if ( obj instanceof Map ) {
            ( ( Map ) obj ).remove( "echoString" );
        }
        // ~

        TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

        MultiServiceProcessor wrapper = new MultiServiceProcessor();
        wrapper.addProcessor( Demo.class, processor );

        server = new TThreadPoolServer(
                new TThreadPoolServer.Args( serverTransport )
                        .inputProtocolFactory( bFactory )
                        .outputProtocolFactory( bFactory )
                        .inputTransportFactory( getTransportFactory() )
                        .outputTransportFactory( getTransportFactory() )
                        .processor( wrapper ) );

        Thread startTread = new Thread() {

            @Override
            public void run() {

                server.serve();
            }

        };

        startTread.start();

        while ( !server.isServing() ) {
            Thread.sleep( 100 );
        }

    }
 
Example 8
Source File: ServiceMethodNotFoundTest.java    From dubbox-hystrix with Apache License 2.0 2 votes vote down vote up
protected void init() throws Exception {

        TServerTransport serverTransport = new TServerSocket( PORT );

        DubboDemoImpl impl = new DubboDemoImpl();

        $__DemoStub.Processor processor = new $__DemoStub.Processor( impl );

        // for test
        Field field = processor.getClass().getSuperclass().getDeclaredField( "processMap" );

        field.setAccessible( true );

        Object obj = field.get( processor );

        if ( obj instanceof Map ) {
            ( ( Map ) obj ).remove( "echoString" );
        }
        // ~

        TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

        MultiServiceProcessor wrapper = new MultiServiceProcessor();
        wrapper.addProcessor( Demo.class, processor );

        server = new TThreadPoolServer(
                new TThreadPoolServer.Args( serverTransport )
                        .inputProtocolFactory( bFactory )
                        .outputProtocolFactory( bFactory )
                        .inputTransportFactory( getTransportFactory() )
                        .outputTransportFactory( getTransportFactory() )
                        .processor( wrapper ) );

        Thread startTread = new Thread() {

            @Override
            public void run() {

                server.serve();
            }

        };

        startTread.start();

        while ( !server.isServing() ) {
            Thread.sleep( 100 );
        }

    }
 
Example 9
Source File: ServiceMethodNotFoundTest.java    From dubbox with Apache License 2.0 2 votes vote down vote up
protected void init() throws Exception {

        TServerTransport serverTransport = new TServerSocket( PORT );

        DubboDemoImpl impl = new DubboDemoImpl();

        $__DemoStub.Processor processor = new $__DemoStub.Processor( impl );

        // for test
        Field field = processor.getClass().getSuperclass().getDeclaredField( "processMap" );

        field.setAccessible( true );

        Object obj = field.get( processor );

        if ( obj instanceof Map ) {
            ( ( Map ) obj ).remove( "echoString" );
        }
        // ~

        TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

        MultiServiceProcessor wrapper = new MultiServiceProcessor();
        wrapper.addProcessor( Demo.class, processor );

        server = new TThreadPoolServer(
                new TThreadPoolServer.Args( serverTransport )
                        .inputProtocolFactory( bFactory )
                        .outputProtocolFactory( bFactory )
                        .inputTransportFactory( getTransportFactory() )
                        .outputTransportFactory( getTransportFactory() )
                        .processor( wrapper ) );

        Thread startTread = new Thread() {

            @Override
            public void run() {

                server.serve();
            }

        };

        startTread.start();

        while ( !server.isServing() ) {
            Thread.sleep( 100 );
        }

    }
 
Example 10
Source File: ServiceMethodNotFoundTest.java    From dubbox with Apache License 2.0 2 votes vote down vote up
protected void init() throws Exception {

        TServerTransport serverTransport = new TServerSocket( PORT );

        DubboDemoImpl impl = new DubboDemoImpl();

        $__DemoStub.Processor processor = new $__DemoStub.Processor( impl );

        // for test
        Field field = processor.getClass().getSuperclass().getDeclaredField( "processMap" );

        field.setAccessible( true );

        Object obj = field.get( processor );

        if ( obj instanceof Map ) {
            ( ( Map ) obj ).remove( "echoString" );
        }
        // ~

        TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

        MultiServiceProcessor wrapper = new MultiServiceProcessor();
        wrapper.addProcessor( Demo.class, processor );

        server = new TThreadPoolServer(
                new TThreadPoolServer.Args( serverTransport )
                        .inputProtocolFactory( bFactory )
                        .outputProtocolFactory( bFactory )
                        .inputTransportFactory( getTransportFactory() )
                        .outputTransportFactory( getTransportFactory() )
                        .processor( wrapper ) );

        Thread startTread = new Thread() {

            @Override
            public void run() {

                server.serve();
            }

        };

        startTread.start();

        while ( !server.isServing() ) {
            Thread.sleep( 100 );
        }

    }