Package de.netseeker.ejoe

Examples of de.netseeker.ejoe.EJServer


     */
    private static final Logger logger = Logger.getLogger( EchoServer.class.getName() );

    public static void main( String[] args )
    {
        EJServer server = new EJServer( new EchoHandler(), 9999 );
        server.setMaxReadProcessors( 1 );
        server.setMaxWriteProcessors( 1 );
        server.enableNonBlockingIO( true );
        server.enablePersistentConnections( true );
        try
        {
            server.start();
        }
        catch ( IOException e )
        {
            logger.log( Level.SEVERE, "Exception while starting server!", e );
        }
View Full Code Here


    /**
     * @param args
     */
    public static void main( String[] args )
    {
        EJServer server = new EJServer( new EchoHandler(), 80 );
        server.setMaxReadProcessors( 1 );
        server.setMaxWriteProcessors( 1 );
        server.enableNonBlockingIO( true );
        server.enablePersistentConnections( true );
        server.enableHttpPackaging( true );
        server.enableCompression( true );
        try
        {
            server.start();
        }
        catch ( IOException e )
        {
            logger.log( Level.SEVERE, "Exception while starting server!", e );
        }
View Full Code Here

*/
public class ServerStarter
{
    public static void main( String[] args )
    {
        EJServer server = new EJServer( new RemoteTestHandler() );
        server.enableRemoteClassLoading( true );
        server.enableNonBlockingIO( true );
        server.enableThreadPoolResizeControl( true );
        server.enablePersistentConnections( true );
        server.enableRemoteClassLoading( true );
        try
        {
            server.start();
        }
        catch ( IOException e )
        {
            e.printStackTrace();
        }
View Full Code Here

*/
public class RemotingServerStarter
{
    public static void main( String[] args )
    {
        EJServer server = new EJServer( new DefaultRemotingHandler() );
        server.enableRemoteClassLoading( true );
        server.enableNonBlockingIO( true );
        server.enableThreadPoolResizeControl( true );
        server.enablePersistentConnections( true );
        server.enableRemoteClassLoading( true );
        try
        {
            server.start();
        }
        catch ( IOException e )
        {
            e.printStackTrace();
        }
View Full Code Here

     * @return
     */
    public static InJvmProcessor createProcessor(ConnectionHeader clientHeader)
    {
        EJServerRegistry registry = EJServerRegistry.getInstance();
        EJServer server = registry.lookup();
        return new InJvmProcessor(server.getServerInfo(), clientHeader);
    }
View Full Code Here

     *
     * @see de.netseeker.ejoe.ServerRegistry#lookup()
     */
    public synchronized EJServer lookup()
    {
        EJServer server = null;      

        if ( registry.size() > 0 )
        {
            Iterator it = registry.values().iterator();

            while ( it.hasNext() )
            {
                server = (EJServer) registry.values().iterator().next();
                if ( server.isRunning() )
                {
                    return server;
                }
                else
                {
View Full Code Here

     */
    public EJServerConfig()
    {
        super();
        ServerHandler handler = null;
        this._ejServer = new EJServer( handler );
        this._ejServer.setMaxReadProcessors( 1 );
        this._ejServer.setMaxWriteProcessors( 1 );
        startEJServer();
    }
View Full Code Here

*/
public class AddressServer
{
    public static void main( String[] args )
    {
        EJServer server = new EJServer( new DefaultRemotingHandler() );
        server.setMaxReadProcessors( 1 );
        server.setMaxWriteProcessors( 1 );
        server.enableNonBlockingIO( true );
        server.enablePersistentConnections( true );
        try
        {
            server.start();
        }
        catch ( IOException e )
        {
            e.printStackTrace();
            System.exit( -1 );
View Full Code Here

     * @see junit.framework.TestCase#setUp()
     */
    protected void setUp() throws Exception
    {
        super.setUp();
        server = new EJServer( new DefaultRemotingHandler() );
        server.enablePersistentConnections( true );

        try
        {
            server.start();
View Full Code Here

            fileName += ".";
            fileName += loops;
            fileName += ".csv";
            List results = new ArrayList();

            EJServer server = new EJServer( new TestHandler(), port );
            server.setMaxReadProcessors( 1 );
            server.setMaxWriteProcessors( 1 );
            server.enablePersistentConnections( true );
            server.enableNonBlockingIO( runs < 2 );
            server.enableCompression( runs == 1 || runs == 3 );
            server.enablePersistentConnections( true );

            try
            {
                System.out.println( "Starting EJServer..." );
                server.start();
                System.out.println( "Waiting 3 seconds..." );
                Thread.sleep( 3000 );
                System.out.println( "Running warmup for each adapter..." );

                for ( int i = 0; i < adapters.length; i++ )
                {
                    System.out.println( "Running warmup for " + adapters[i] );
                    EJClient client = new EJClient( "localhost", port, adapters[i] );
                    client.enablePersistentConnection( true );
                    client.enableCompression( runs == 1 || runs == 3 );
                    client.setInJVM( true );
                    try
                    {
                        for ( int t = 0; t < 5; t++ )
                            client.execute( new ObjectBean() );
                    }
                    finally
                    {
                        client.close();
                    }
                }
            }
            catch ( Exception e1 )
            {
                e1.printStackTrace();
                System.exit( -1 );
            }

            System.out.println( "Waiting 3 seconds..." );
            try
            {
                Thread.sleep( 3000 );
            }
            catch ( InterruptedException e1 )
            {
                e1.printStackTrace();
                System.exit( -1 );
            }

            Object result = null;

            String[] msgs = new String[3];

            for ( int i = 0; i < adapters.length; i++ )
            {
                EJClient client = new EJClient( "localhost", port, adapters[i] );
                client.enablePersistentConnection( true );
                client.enableCompression( runs == 1 || runs == 3 );
                client.setInJVM( true );

                System.out.println( "Running test on " + adapters[i] + " with target " + fileName );

                Date start = new Date();

                try
                {
                    for ( int go = 0; go < loops; go++ )
                    {
                        try
                        {
                            result = client.execute( new ObjectBean() );
                        }
                        catch ( Throwable e )
                        {
                            msgs[2] = "Exception occured while processing the request!" + e + ':' + e.getMessage();
                            go = runs;
                            break;
                        }
                    }
                }
                finally
                {
                    client.close();
                }

                Date end = new Date();
                long duration = end.getTime() - start.getTime();
                DateFormat df = new SimpleDateFormat( dFormat );
                BigDecimal resultF = BigDecimal.valueOf( (duration * 1.00) / (loops * 1.00) )
                        .setScale( 2, BigDecimal.ROUND_HALF_UP );
                DecimalFormat dcf = new DecimalFormat( "###.##" );

                msgs[0] = adapters[i].getClass().getName() + ';' + df.format( start ) + ';' + df.format( end ) + ';'
                        + duration + ";" + dcf.format( resultF );
                msgs[1] = "-1";

                if ( result == null || !(result instanceof ObjectBean)
                        || !((ObjectBean) result).getTheString().equals( "Accepted" ) )
                {
                    msgs[2] = "Errors during (de)serialization! Server returned: "
                            + (result != null ? (result.getClass().getName() + ':' + result) : "null");
                }
                else
                {
                    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
                    SerializeAdapter adpt = adapters[i];
                    try
                    {
                        if ( runs == 1 || runs == 3 )
                        {
                            DeflaterOutputStream sOut = new GZIPOutputStream( bOut, EJConstants.BUFFERED_STREAM_SIZE )
                                {
                                    {
                                        def.setLevel( EJConstants.DEFAULT_COMPRESSION_LEVEL );
                                    }
                                };
                            adpt.write( new ObjectBean(), sOut );
                            sOut.finish();
                            sOut.close();
                        }
                        else
                        {
                            adpt.write( new ObjectBean(), bOut );
                        }
                        msgs[1] = String.valueOf( bOut.size() );
                    }
                    catch ( Exception e )
                    {
                        e.printStackTrace();
                    }
                }

                results.add( msgs[0] + ';' + msgs[1] + ";" + (msgs[2] != null ? msgs[2] : "") );

                msgs[0] = null;
                msgs[1] = null;
                msgs[2] = null;
            }

            try
            {
                System.out.println( "Creating file " + fileName );
                BufferedWriter out = new BufferedWriter( new FileWriter( fileName ) );
                out.write( header );
                out.write( "\r\n" );
                for ( Iterator it = results.iterator(); it.hasNext(); )
                {
                    out.write( (String) it.next() );
                    out.write( "\r\n" );
                }
                out.close();
            }
            catch ( IOException e )
            {
                e.printStackTrace();
            }

            System.out.println( "Stopping server..." );
            server.stop();
            port++;

            if ( runs < 3 )
            {
                try
View Full Code Here

TOP

Related Classes of de.netseeker.ejoe.EJServer

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.