public static GridNode createGridNode(String id){ Grid grid = new GridImpl( new HashMap<String, Object>() ); return grid.createGridNode( id ); }
public void addService(Class cls, Object service) { addService( cls.getName(), service ); }
public GridImpl( String id, Map<String, Object> services ) { if ( services == null ) { this.services = new ConcurrentHashMap<String, Object>(); } else { this.services = services; } this.id = id; init(); }
public GridNode createGridNode( String id ) { if ( logger.isDebugEnabled() ) { logger.debug( " ### GridImpl: Registering in white pages (grid = " + getId() + ") new node = " + id ); } WhitePages wp = get( WhitePages.class ); GridServiceDescription gsd = wp.create( id, this.id ); gsd.setServiceInterface( GridNode.class ); GridNode node = new GridNodeImpl( id, this ); this.localNodes.put( id , node ); return node; }
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; }
@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 ); }
public <T> T get( Class<T> serviceClass ) { return get( serviceClass, false ); }
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; }
GridImpl grid1 = new GridImpl("peer1", new ConcurrentHashMap<String, Object>() ); GridImpl grid2 = new GridImpl( "peer2", new ConcurrentHashMap<String, Object>() ); conf = new GridPeerConfiguration(); WhitePages wpClient = grid2.get( WhitePages.class ); testGsd_2 ); WhitePages localWhitePages = grid1.get( WhitePages.class ); GridServiceDescription testGsd_3 = localWhitePages.lookup( "test:string@domain1" ); testGsd_3 ); grid1.get( SocketService.class ).close();
public GridNode claimGridNode( String id ) { if ( logger.isDebugEnabled() ) { logger.debug( " ### GridImpl: Claiming orphan node " + id + " found in white pages (grid = " + getId() + ") " ); } WhitePages wp = get( WhitePages.class ); wp.remove( id ); GridServiceDescription gsd = wp.create( id, this.id ); gsd.setServiceInterface( GridNode.class ); GridNode node = new GridNodeImpl( id, this ); this.localNodes.put( id , node ); return node; }
public void removeGridNode( String id ) { WhitePages wp = get( WhitePages.class ); wp.remove( id ); this.localNodes.remove( 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 ); }
@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; }
public void addService(Class cls, Object service) { addService( cls.getName(), service ); }
public GridImpl(Map<String, Object> services) { if ( services == null ) { this.services = new ConcurrentHashMap<String, Object>(); } else { this.services = services; } this.id = UUID.randomUUID().toString(); init(); }
WhitePages wp = get( WhitePages.class, false ); if ( wp != null ) { for ( String nodeId : localNodes.keySet() ) { logger.error( " Grid couldn't unregister all local nodes " + t.getMessage(), t ); } finally { SocketService socketService = get( SocketService.class ); if ( socketService != null ) { socketService.close();
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 ); }
/** * 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; }
public void addService(Class cls, Object service) { addService( cls.getName(), service ); }