Examples of GridImpl


Examples of org.drools.grid.impl.GridImpl

    }

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

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

        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 );

        String rule = "package test\n"
                + "import org.drools.grid.NodeTests.MyObject;\n"
                + "global MyObject myGlobalObj;\n"
                + "global org.drools.grid.Grid grid; \n"
                + "rule \"test\""
                + "  when"
                + "       $o: MyObject()"
                + "  then"
                + "      System.out.println(\"My Global Object -> \"+myGlobalObj.getName());"
                + "      System.out.println(\"Rule Fired! ->\"+$o.getName());"
                + " end";

        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();

        Assert.assertNotNull( kbase );

        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();

        Assert.assertNotNull( session );
        session.setGlobal("myGlobalObj", new MyObject("myGlobalObj"));

        FactHandle handle = session.insert( new MyObject("myObj1") );
        Assert.assertNotNull( handle );

        int fired = session.fireAllRules();
        Assert.assertEquals( 1,
                fired );

        session.retract(handle);


        handle = session.insert(new MyObject("myObj2"));

        session.update(handle, new MyObject("myObj3"));

        fired = session.fireAllRules();

        grid1.dispose();
        grid2.dispose();
        assertTrue( remoteN1.isDisposed() );
        assertTrue( n1.isDisposed() );

    }
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

        Map<String, GridServiceDescription> coreServicesMap = new HashMap<String, GridServiceDescription>();//Hazelcast.newHazelcastInstance( null ).getMap( CoreServicesLookup.class.getName() );

        SystemEventListener l = SystemEventListenerFactory.getSystemEventListener();

        GridImpl grid1 = new GridImpl("peer", new ConcurrentHashMap<String, Object>() );

        GridPeerConfiguration conf = new GridPeerConfiguration();

        GridPeerServiceConfiguration coreSeviceConf = new CoreServicesLookupConfiguration( coreServicesMap );
        conf.addConfiguration( coreSeviceConf );

        MultiplexSocketServiceConfiguration socketConf = new MultiplexSocketServiceConfiguration( new MultiplexSocketServerImpl( "127.0.0.1",
                                                                                                                          new MinaAcceptorFactoryService(),
                                                                                                                          l,
                                                                                                                          grid1 ) );
        conf.addConfiguration( socketConf );

        WhitePagesLocalConfiguration wplConf = new WhitePagesLocalConfiguration();
        wplConf.setWhitePages( new JpaWhitePages( Persistence.createEntityManagerFactory( "org.drools.grid" ) ) );
        conf.addConfiguration( wplConf );

        socketConf.addService( WhitePages.class.getName(), wplConf.getWhitePages(), 8000 );

        conf.configure( grid1 );

        GridImpl grid2 = new GridImpl( new ConcurrentHashMap<String, Object>() );
        conf = new GridPeerConfiguration();

        //coreServicesMap = Hazelcast.newHazelcastInstance( null ).getMap( CoreServicesLookup.class.getName() );
        coreSeviceConf = new CoreServicesLookupConfiguration( coreServicesMap );
        conf.addConfiguration( coreSeviceConf );

        GridPeerServiceConfiguration wprConf = new WhitePagesRemoteConfiguration( );
        conf.addConfiguration( wprConf );

        conf.configure( grid2 );

        WhitePages wp = grid2.get( WhitePages.class );

        wp.create( "s1", "grid0" );
        wp.create( "s2", "grid0" );
        wp.create( "s3", "grid0" );
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    public void test1() throws Exception {
        Map<String, GridServiceDescription> coreServicesMap = new HashMap<String, GridServiceDescription>();//Hazelcast.newHazelcastInstance( null ).getMap( CoreServicesLookup.class.getName() );

        SystemEventListener l = SystemEventListenerFactory.getSystemEventListener();

        GridImpl grid1 = new GridImpl("peer1", new ConcurrentHashMap<String, Object>() );

        GridPeerConfiguration conf = new GridPeerConfiguration();

        GridPeerServiceConfiguration coreSeviceConf = new CoreServicesLookupConfiguration( coreServicesMap );
        conf.addConfiguration( coreSeviceConf );

        MultiplexSocketServiceConfiguration socketConf = new MultiplexSocketServiceConfiguration( new MultiplexSocketServerImpl( "127.0.0.1",
                                                                                                                          new MinaAcceptorFactoryService(),
                                                                                                                          l,
                                                                                                                          grid1) );
        conf.addConfiguration( socketConf );

        WhitePagesLocalConfiguration wplConf = new WhitePagesLocalConfiguration();
        conf.addConfiguration( wplConf );

        socketConf.addService( WhitePages.class.getName(), wplConf.getWhitePages(), 8000 );

        conf.configure( grid1 );

        GridImpl grid2 = new GridImpl( "peer2", new ConcurrentHashMap<String, Object>() );
        conf = new GridPeerConfiguration();

        //coreServicesMap = Hazelcast.newHazelcastInstance( null ).getMap( CoreServicesLookup.class.getName() );
        coreSeviceConf = new CoreServicesLookupConfiguration( coreServicesMap );
        conf.addConfiguration( coreSeviceConf );

        GridPeerServiceConfiguration wprConf = new WhitePagesRemoteConfiguration( );
        conf.addConfiguration( wprConf );

        conf.configure( grid2 );

        WhitePages wpClient = grid2.get( WhitePages.class );

        GridServiceDescription test1Gsd = wpClient.create( "test:string@domain1", "grid0" );

        GridServiceDescription testGsd_2 = wpClient.lookup( "test:string@domain1" );
        assertEquals( test1Gsd,
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    public void testWhitePagesLookupServices() {
        Map<String, GridServiceDescription> coreServicesMap = new HashMap<String, GridServiceDescription>();//Hazelcast.newHazelcastInstance( null ).getMap( CoreServicesLookup.class.getName() );

        SystemEventListener l = SystemEventListenerFactory.getSystemEventListener();

        GridImpl grid1 = new GridImpl( new ConcurrentHashMap<String, Object>() );

        GridPeerConfiguration conf = new GridPeerConfiguration();

        GridPeerServiceConfiguration coreSeviceConf = new CoreServicesLookupConfiguration( coreServicesMap );
        conf.addConfiguration( coreSeviceConf );

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

        //Create a Local Scheduler
        GridPeerServiceConfiguration schlConf = new SchedulerLocalConfiguration( "myLocalSched1" );
        conf.addConfiguration( schlConf );

        //Create a Local Scheduler
        GridPeerServiceConfiguration schlConf2 = new SchedulerLocalConfiguration( "myLocalSched2" );
        conf.addConfiguration( schlConf2 );

        conf.configure( grid1 );

        WhitePages wplocal = grid1.get( WhitePages.class );
        assertNotNull( wplocal );
        GridServiceDescription schedulersgsd = wplocal.lookup( "scheduler:" + "myLocalSched1" + SchedulerService.class.getName() );

        assertNotNull( schedulersgsd );
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

                                         8000 ),
                  accHandler,
                  l );


        ConversationManager cm = new ConversationManagerImpl( new GridImpl("peer"),
                                                              l );

        Conversation cv = cm.startConversation( "s1",
                                                new InetSocketAddress( "127.0.0.1",
                                                                       8000 ),
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    protected CommandExecutor exec2;

    protected Context createJndiContext() throws Exception {
        Context context = super.createJndiContext();

        GridImpl grid = new GridImpl( new HashMap() );
        node = grid.createGridNode( "local" );
       
        node.set( "ksession1",
                  this.exec );
       
      
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    protected CommandExecutor exec2;

    protected Context createJndiContext() throws Exception {
        Context context = super.createJndiContext();

        GridImpl grid = new GridImpl( new HashMap() );
        grid.addService( WhitePages.class,
                         new WhitePagesImpl() );
        node = grid.createGridNode( "local" );
       
        node.set( "ksession1",
                  this.exec );
       
      
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

public class DroolsBlueprintBean {


    public static GridNode createGridNode(String id){
        Grid grid = new GridImpl( new HashMap<String, Object>() );
        return grid.createGridNode( id );
    }
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

public class DroolsBlueprintBean {


    public static GridNode createGridNode(String id){
        Grid grid = new GridImpl( new HashMap<String, Object>() );
        return grid.createGridNode( id );
    }
View Full Code Here

Examples of org.drools.grid.impl.GridImpl

    public boolean isSingleton() {
        return true;
    }

    public void afterPropertiesSet() throws Exception {
        this.grid = new GridImpl( new HashMap() );
//        MultiplexSocketServiceCongifuration socketConf = null;
//
//        if ( this.coreServices == null ) {
//            this.coreServices = new HashMap();
//        }
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.