Examples of GridImpl


Examples of org.drools.grid.impl.GridImpl

                               KnowledgeBase.class ) );
    }

    @Test
    public void testNodeCreationAndWhitePagesRegistration() {
        Grid grid = new GridImpl( new HashMap<String, Object>() );

        GridPeerConfiguration conf = new GridPeerConfiguration();

        //Configuring the WhitePages
        GridPeerServiceConfiguration wplConf = new WhitePagesLocalConfiguration();
        conf.addConfiguration( wplConf );

        conf.configure( grid );

        GridNode gnode = grid.createGridNode( "test1@local" );

        WhitePages pages = grid.get( WhitePages.class );
        GridServiceDescription<GridNode> gsd = pages.create( "test1@local", "grid0" );
       
        GridServiceDescription<GridNode> serviceDescription = pages.lookup( "test1@local" );

        GridConnection connection = grid.get( ConnectionFactoryService.class ).createConnection( gsd );
        assertSame( gnode,
                    connection.connect() );
    }
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    public void tearDown() {
    }

    @Test
    public void localNodeTest() {
        Grid grid = new GridImpl( new HashMap<String, Object>() );
        GridPeerConfiguration conf = new GridPeerConfiguration();

        GridPeerServiceConfiguration wpconf = new WhitePagesLocalConfiguration();
        conf.addConfiguration( wpconf );

        conf.configure( grid );

        GridNode gnode = grid.createGridNode( "n1" );

        KnowledgeBuilder kbuilder = gnode.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder();
        assertNotNull( kbuilder );

        KnowledgeBase kbase = gnode.get( KnowledgeBaseFactoryService.class ).newKnowledgeBase();
        assertNotNull( kbase );

        StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
        assertNotNull( session );

        WhitePages wp = grid.get( WhitePages.class );
        GridServiceDescription gsd = wp.lookup( "n1" );
        assertNotNull(gsd);
        assertEquals( 0, gsd.getAddresses().size() );

        gnode = grid.getGridNode( gsd.getId() );
        assertNotNull( gnode );
       
        grid.removeGridNode( gsd.getId() );
        assertNull( wp.lookup( "n1" ) );
        assertNull( grid.getGridNode( gsd.getId() ) );
       
    }
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    }


    @Test
    public void remoteNodeTest() {
        Grid grid1 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid1,
                        8000,
                        new WhitePagesImpl() );

        Grid grid2 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid2,
                        -1,
                        null );

        GridNode n1 = grid1.createGridNode( "n1" );
        grid1.get( SocketService.class ).addService( "n1", 8000, n1 );
              
        GridServiceDescription<GridNode> n1Gsd = grid2.get( WhitePages.class ).lookup( "n1" );
        GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
        GridNode remoteN1 = conn.connect();

        KnowledgeBuilder kbuilder = remoteN1.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder();

        Assert.assertNotNull( kbuilder );
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    }
   
     @Test
    public void remoteNodeRetractUpdateGlobalsTest() {
        Grid grid1 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid1,
                        8000,
                        new WhitePagesImpl() );

        Grid grid2 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid2,
                        -1,
                        null );

        GridNode n1 = grid1.createGridNode( "n1" );
        grid1.get( SocketService.class ).addService( "n1", 8000, n1 );
              
        GridServiceDescription<GridNode> n1Gsd = grid2.get( WhitePages.class ).lookup( "n1" );
        GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
        GridNode remoteN1 = conn.connect();

        KnowledgeBuilder kbuilder = remoteN1.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder();

        Assert.assertNotNull( kbuilder );
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

        server.stop();
       
    }
   
    private GridServiceDescription createRemoteNode(){
        grid1 = new GridImpl("peer1", new HashMap<String, Object>() );
        configureGrid1( grid1,
                        8000,
                        new JpaWhitePages(Persistence.createEntityManagerFactory("org.drools.grid")) );

        Grid grid2 = new GridImpl("peer2", new HashMap<String, Object>() );
        configureGrid1( grid2,
                        -1,
                        grid1.get( WhitePages.class ) );

        GridNode n1 = grid1.createGridNode( "n1" );
        grid1.get( SocketService.class ).addService( "n1", 8000, n1 );
              
        GridServiceDescription<GridNode> n1Gsd = grid2.get( WhitePages.class ).lookup( "n1" );
        GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
        remoteN1 = conn.connect();
       
        return n1Gsd;
   
    }
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

        //System.out.println("Response 1 = "+ response );
        assertTrue( response.contains( "execution-results" ) );
        assertTrue( response.contains( "echo" ) );
       
       
        GridImpl grid2 = (GridImpl) springContext.getBean("grid2");
        GridServiceDescription<GridNode> n1Gsd = grid2.get( WhitePages.class ).lookup( "node1" );
        GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
        GridNode remoteN1 = conn.connect();

        KnowledgeBuilder kbuilder = remoteN1.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder();

        assertNotNull( kbuilder );
       
        String rule = "package  org.grid.test\n"
                + "declare Message2\n"
                +    "text : String\n"
                + "end\n"
                + "rule \"echo2\" \n"
                + "dialect \"mvel\"\n"
                +   "when\n"
                + "     $m : Message2()\n"
                +   "then\n"
                +       "$m.text = \"echo2:\" + $m.text;\n"
                + "end\n";
                //System.out.println("Rule = "+rule);
        kbuilder.add( new ByteArrayResource( rule.getBytes() ),
                      ResourceType.DRL );

        KnowledgeBuilderErrors errors = kbuilder.getErrors();
        if ( errors != null && errors.size() > 0 ) {
            for ( KnowledgeBuilderError error : errors ) {
                System.out.println( "Error: " + error.getMessage() );

            }
            fail("KnowledgeBase did not build");
        }

        KnowledgeBase kbase = remoteN1.get( KnowledgeBaseFactoryService.class ).newKnowledgeBase();

        assertNotNull( kbase );

        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();

        assertNotNull( session );
       
       
        remoteN1.set("ksession2", session);
       
       
        soapMessage = createMessageForKsession("ksession2");
       
        String response2 = test.execute( soapMessage,
                                        (CamelContext) springContext.getBean( "camel-client-ctx" ) );
       
        //System.out.println("Response 2 = "+response2  );
        assertTrue( response2.contains( "execution-results" ) );
        assertTrue( response2.contains( "echo2" ) );
       
        remoteN1.dispose();
        GridImpl grid1 = (GridImpl) springContext.getBean("grid1");
        grid1.get(SocketService.class).close();
      
        springContext.registerShutdownHook();
        springContext.stop();
       
    }
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    public void tearDown() {
    }

    @Test
    public void localNodeTest() {
        Grid grid = new GridImpl( new HashMap<String, Object>() );
        GridPeerConfiguration conf = new GridPeerConfiguration();

        GridPeerServiceConfiguration wpconf = new WhitePagesLocalConfiguration();
        conf.addConfiguration( wpconf );

        conf.configure( grid );

        GridNode gnode = grid.createGridNode( "n1" );

        KnowledgeBuilder kbuilder = gnode.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder();
        assertNotNull( kbuilder );

        KnowledgeBase kbase = gnode.get( KnowledgeBaseFactoryService.class ).newKnowledgeBase();
        assertNotNull( kbase );

        StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
        assertNotNull( session );

        WhitePages wp = grid.get( WhitePages.class );
        GridServiceDescription gsd = wp.lookup( "n1" );
        assertNotNull(gsd);
        assertEquals( 0, gsd.getAddresses().size() );

        gnode = grid.getGridNode( gsd.getId() );
        assertNotNull( gnode );
       
        grid.removeGridNode( gsd.getId() );
        assertNull( wp.lookup( "n1" ) );       
        assertNull( grid.getGridNode( gsd.getId() ) );
       
    }
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    }


    @Test
    public void remoteNodeTest() {
        Grid grid1 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid1,
                        8000,
                        new WhitePagesImpl() );

        Grid grid2 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid2,
                        -1,
                        null );

        GridNode n1 = grid1.createGridNode( "n1" );
        grid1.get( SocketService.class ).addService( "n1", 8000, n1 );
              
        GridServiceDescription<GridNode> n1Gsd = grid2.get( WhitePages.class ).lookup( "n1" );
        GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
        GridNode remoteN1 = conn.connect();

        KnowledgeBuilder kbuilder = remoteN1.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder();

        Assert.assertNotNull( kbuilder );
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    }
   
     @Test
    public void remoteNodeRetractUpdateGlobalsTest() {
        Grid grid1 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid1,
                        8000,
                        new WhitePagesImpl() );

        Grid grid2 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid2,
                        -1,
                        null );

        GridNode n1 = grid1.createGridNode( "n1" );
        grid1.get( SocketService.class ).addService( "n1", 8000, n1 );
              
        GridServiceDescription<GridNode> n1Gsd = grid2.get( WhitePages.class ).lookup( "n1" );
        GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
        GridNode remoteN1 = conn.connect();

        KnowledgeBuilder kbuilder = remoteN1.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder();

        Assert.assertNotNull( kbuilder );
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

        remoteN1.dispose();
        grid1.get(SocketService.class).close();
    }
   
    private void createRemoteNode(){
        grid1 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid1,
                        8000,
                        null );

        Grid grid2 = new GridImpl( new HashMap<String, Object>() );
        configureGrid1( grid2,
                        -1,
                        grid1.get( WhitePages.class ) );

        GridNode n1 = grid1.createGridNode( "n1" );
        grid1.get( SocketService.class ).addService( "n1", 8000, n1 );
              
        GridServiceDescription<GridNode> n1Gsd = grid2.get( WhitePages.class ).lookup( "n1" );
        GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
        remoteN1 = conn.connect();
   
    }
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.