public static GridNode createGridNode(String id){ Grid grid = new GridImpl( new HashMap<String, Object>() ); return grid.createGridNode( id ); }
public void afterPropertiesSet() throws Exception { if ( grid == null ) { this.grid = new GridImpl( new HashMap<String, Object>() ); // ((GridImpl) this.grid).addService( WhitePages.class, // new WhitePagesImpl() ); } this.node = this.grid.createGridNode( id ); // if ( StringUtils.hasText( this.port ) ) { // this.grid.get( SocketService.class ).addService( id, // Integer.parseInt( port ), // this.node ); // } // connection.addExecutionNode(new LocalNodeConnector()); // connection.addDirectoryNode(new LocalDirectoryConnector()); // node = connection.getExecutionNode(); // node.setId( id ); }
public void afterPropertiesSet() throws Exception { if ( grid == null ) { this.grid = new GridImpl( new HashMap<String, Object>() ); // ((GridImpl) this.grid).addService( WhitePages.class, // new WhitePagesImpl() ); } this.node = this.grid.createGridNode( id ); // if ( StringUtils.hasText( this.port ) ) { // this.grid.get( SocketService.class ).addService( id, // Integer.parseInt( port ), // this.node ); // } // connection.addExecutionNode(new LocalNodeConnector()); // connection.addDirectoryNode(new LocalDirectoryConnector()); // node = connection.getExecutionNode(); // node.setId( id ); }
public void afterPropertiesSet() throws Exception { if ( grid == null ) { this.grid = new GridImpl( new HashMap<String, Object>() ); // ((GridImpl) this.grid).addService( WhitePages.class, // new WhitePagesImpl() ); } this.node = this.grid.createGridNode( id ); // if ( StringUtils.hasText( this.port ) ) { // this.grid.get( SocketService.class ).addService( id, // Integer.parseInt( port ), // this.node ); // } // connection.addExecutionNode(new LocalNodeConnector()); // connection.addDirectoryNode(new LocalDirectoryConnector()); // node = connection.getExecutionNode(); // node.setId( id ); }
public void afterPropertiesSet() throws Exception { this.grid = new GridImpl( new HashMap() );
public void afterPropertiesSet() throws Exception { this.grid = new GridImpl( new HashMap() );
protected Context createJndiContext() throws Exception { Context context = super.createJndiContext(); GridImpl grid = new GridImpl( new HashMap() ); node = grid.createGridNode( "node" ); node.set( "ksession1", this.exec ); context.bind( "node", node ); return context; }
protected Context createJndiContext() throws Exception { Context context = super.createJndiContext(); GridImpl grid = new GridImpl( new HashMap() ); node = grid.createGridNode( "local" ); node.set( "ksession1", this.exec ); context.bind( "node", node ); return context; }
@Override protected Context createJndiContext() throws Exception { // Overriding this method is necessary in the absence of a spring application context // to bootstrap the whole thing. Create another Spring based unit test with all the beans // defined as below and remove this comment from here. //create Context context = super.createJndiContext(); GridImpl grid = new GridImpl( new HashMap() ); // grid.addService( WhitePages.class, // new WhitePagesImpl() ); node = grid.createGridNode( "node" ); context.bind( "node", node ); configureDroolsContext( context ); return context; }
private GridServiceDescription createRemoteNode(){ wps = new JpaWhitePages( Persistence.createEntityManagerFactory("org.drools.grid") ); grid1 = new GridImpl("peer1", new HashMap<String, Object>() ); configureGrid1( grid1, 8000, wps ); grid2 = new GridImpl("peer2", new HashMap<String, Object>() ); configureGrid1( grid2, -1, wps ); 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; }
/** * configures camel-drools integration and defines 3 routes: * 1) testing route (connection to drools with JSON command format) * 2) unmarshalling route (for unmarshalling command results) * 3) marshalling route (enables creating commands through API and converting to JSON) */ private CamelContext configure(StatefulKnowledgeSession session) throws Exception { GridImpl grid = new GridImpl(new HashMap()); GridNode node = grid.createGridNode("testnode"); Context context = new JndiContext(); context.bind("testnode", node); node.set("ksession", session); CamelContext camelContext = new DefaultCamelContext(context); camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:test-session").policy(new DroolsPolicy()).unmarshal("json").to("drools://testnode/ksession").marshal("json"); from("direct:unmarshall").policy(new DroolsPolicy()).unmarshal("json"); from("direct:marshall").policy(new DroolsPolicy()).marshal("json"); } }); return camelContext; }
GridImpl grid = new GridImpl(new HashMap<String, Object>()); GridNode node = grid.createGridNode("testnode");
ConversationManager cm = new ConversationManagerImpl( new GridImpl("peer"), l );
@Test 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 ); }
@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() ); grid.dispose(); }
@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() ); GridNode gnode1 = grid.getGridNode( gsd.getId() ); assertNotNull( gnode1 ); grid.removeGridNode( gsd.getId() ); assertNull( wp.lookup( "n1" ) ); assertNull( grid.getGridNode( gsd.getId() ) ); grid.dispose(); // node has been removed, so disposal should not affect it assertFalse( gnode.isDisposed() ); gnode.dispose(); assertTrue( gnode.isDisposed() ); }