public <T> T get( Class<T> serviceClass ) { return get( serviceClass, false ); }
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; }
public void removeGridNode( String id ) { WhitePages wp = get( WhitePages.class ); wp.remove( id ); this.localNodes.remove( id ); }
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; }
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 GridNode asRemoteNode( GridNode node ) { if ( node.isRemote() ) { return node; } GridServiceDescription<GridNode> nGsd = this.get( WhitePages.class ).lookup( node.getId() ); ConnectionFactoryService cfs = get( ConnectionFactoryService.class ); boolean allowsLocal = cfs.isLocalAllowed(); cfs.setLocalAllowed( false ); GridConnection<GridNode> conn = cfs.createConnection( nGsd ); if ( logger.isDebugEnabled() ) { logger.debug( " ### Session Manager: Opened connection to node: " + conn ); } // forcing a remote connection to the node cfs.setLocalAllowed( allowsLocal ); GridNodeRemoteClient rem = (GridNodeRemoteClient) conn.connect(); rem.setLocalProxy( true ); this.localNodes.put( node.getId() + "$$LocalProxy", rem ); return rem; }
@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 ); }