Package com.sun.sgs.service

Examples of com.sun.sgs.service.NodeMappingService


            // location of identities for the accesses below
            // node1: 1,4,7,10,13,16,19,22,25,28,31,34
            // node2: 2,5,8,11,14,17,20,23,26,29,32
            // node3: 3,6,9,12,15,18,21,24,27,30,33
            // Actual round robin policy might assign these differently...
            NodeMappingService nms = node1.getNodeMappingService();
            for (int i = 1; i < 35; i++) {
                idents[i] = new DummyIdentity(String.valueOf(i));
                nms.assignNode(this.getClass(), idents[i]);
            }
           
            // Node 1 uses.
            AffinityGraphBuilder builder1 = driver1.getGraphBuilder();
            AccessedObjectsDetailTest detail = new AccessedObjectsDetailTest();
View Full Code Here


           
            // Find the node mapping server
            Field mapServer =
                    NodeMappingServiceImpl.class.getDeclaredField("serverImpl");
            mapServer.setAccessible(true);
            final NodeMappingService nodeMappingService =
                    serverNode.getNodeMappingService();
            NodeMappingServerImpl nodeMappingServer =
                    (NodeMappingServerImpl) mapServer.get(nodeMappingService);
           
            // Create a new identity and assign it to a node
            // Since there is only 1 app node, it will be assigned to that one
            final Identity id = new IdentityImpl(appName + "_identity");
            nodeMappingService.assignNode(NodeMappingService.class, id);
            System.err.println("AppNode id: "+appNode.getNodeId());

            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    // See if the right node has the identity
                    long nodeid = nodeMappingService.getNode(id).getId();
                    System.err.println("Identity is on node: "+nodeid);
                    if (nodeid != appNode.getNodeId())
                        fail("Identity is on the wrong node");
                }
            }, taskOwner);
View Full Code Here

       
        for (int i = 0; i < NUM_NODES; i++) {
            SgsTestNode node =  new SgsTestNode(serverNode, null, props);
            additionalNodes[i] = node;
       
            NodeMappingService nmap = node.getNodeMappingService();

            // Add to our test data structures, so we can find these nodes
            // and listeners.
            TestListener listener = new TestListener();       
            nmap.addNodeMappingListener(listener);
            nodeListenerMap.put(node.getNodeId(), listener);
        }
    }
View Full Code Here

   
        ////////     The tests     /////////
    @Test
    public void testConstructor() {
        NodeMappingService nodemap = null;
        try {
            nodemap =
                new NodeMappingServiceImpl(
                            serviceProps, systemRegistry, txnProxy);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (nodemap != null) { nodemap.shutdown(); }
        }
    }
View Full Code Here

        }
    }

    @Test(expected = NullPointerException.class)
    public void testConstructorNullProperties() throws Exception {
        NodeMappingService nodemap = null;
        try {
            nodemap =
                new NodeMappingServiceImpl(null, systemRegistry, txnProxy);
        } finally {
            if (nodemap != null) { nodemap.shutdown(); }
        }
    }
View Full Code Here

        }
    }
   
    @Test(expected = NullPointerException.class)
    public void testConstructorNullProxy() throws Exception {
        NodeMappingService nodemap = null;
        try {
            nodemap =
              new NodeMappingServiceImpl(serviceProps, systemRegistry, null);
        } finally {
            if (nodemap != null) { nodemap.shutdown(); }
        }
    }
View Full Code Here

                    "TestNodeMappingServiceImpl",
                    serverNode,
                    SgsTestNode.DummyAppListener.class);
        props.remove(StandardProperties.SERVER_HOST);
 
        NodeMappingService nmap =
            new NodeMappingServiceImpl(props, systemRegistry, txnProxy);
    }
View Full Code Here

        new NodeMappingServiceImpl(serviceProps, systemRegistry, txnProxy)
    }
   
    @Test
    public void testReady() throws Exception {
        NodeMappingService nodemap = null;
        try {
            nodemap =
                new NodeMappingServiceImpl(
        SgsTestNode.getDefaultProperties(
      "TestNodeMappingServiceImpl", serverNode, null),
        systemRegistry, txnProxy);
            TestListener listener = new TestListener();       
            nodemap.addNodeMappingListener(listener);
           
            // We have NOT called ready yet.
            final Identity id = new IdentityImpl("first");
            nodemap.assignNode(NodeMappingService.class, id);
           
            txnScheduler.runTask(
                new TestAbstractKernelRunnable() {
                    public void run() throws Exception {
                        nodeMappingService.getNode(id);
                    }
                }, taskOwner);
           
            // Ensure the listener has not been called yet.
            assertTrue(listener.isClear());

            nodemap.ready();
            // Listener should be notified
            listener.waitForNotification();
           
            // no old node
            checkIdAdded(listener, id, null);
        } finally {
            if (nodemap != null) { nodemap.shutdown(); }
        }
    }
View Full Code Here

           
            // Find the node mapping server
            Field mapServer =
                    NodeMappingServiceImpl.class.getDeclaredField("serverImpl");
            mapServer.setAccessible(true);
            final NodeMappingService nodeMappingService =
                    serverNode.getNodeMappingService();
            NodeMappingServerImpl nodeMappingServer =
                    (NodeMappingServerImpl) mapServer.get(nodeMappingService);
           
            // Create a new identity and assign it to a node
            // Since there is only 1 app node, it will be assigned to that one
            final Identity id = new IdentityImpl(appName + "_identity");
            nodeMappingService.assignNode(NodeMappingService.class, id);
            System.err.println("AppNode id: "+appNode.getNodeId());

            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    // See if the right node has the identity
                    long nodeid = nodeMappingService.getNode(id).getId();
                    System.err.println("Identity is on node: "+nodeid);
                    if (nodeid != appNode.getNodeId())
                        fail("Identity is on the wrong node");
                }
            }, taskOwner);
View Full Code Here

TOP

Related Classes of com.sun.sgs.service.NodeMappingService

Copyright © 2018 www.massapicom. 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.