Package com.sun.sgs.service

Examples of com.sun.sgs.service.Node


     * failure) fails before it has a chance to schedule a task
     * to remove the server node ID for another failed node
     * (cascading failure during recovery).
     */
    for (long serverNodeId : channel.getServerNodeIds()) {
        Node serverNode = watchdogService.getNode(serverNodeId);
        if (serverNode == null || !serverNode.isAlive()) {
      channel.removeServerNodeId(serverNodeId);
        }
    }
      }

View Full Code Here


     * must be run on the local node.
     * NOTE: we may want to revisit this final assumption, perhaps delaying
     * such tasks, or coming up with some other policy
     */
    private boolean handoffTask(String objName, Identity identity) {
        Node handoffNode = null;
        try {
            handoffNode = nodeMappingService.getNode(identity);
        } catch (UnknownIdentityException uie) {
            // this should be a rare case, but in the event that there isn't
            // a mapping available, there's really nothing to be done except
            // just run the task locally, and in a separate thread try to get
            // the assignment taken care of
            if (logger.isLoggable(Level.INFO)) {
                logger.logThrow(Level.INFO, uie, "No mapping exists for " +
                                "identity {0} so task {1} will run locally",
                                identity.getName(), objName);
            }
            assignNode(identity);
            return false;
        }

        // since the call to get an assigned node can actually return a
        // failed node, check for this case first
        if (!handoffNode.isAlive()) {
            // since the mapped node is down, run the task locally
            if (logger.isLoggable(Level.INFO)) {
                logger.log(Level.INFO, "Mapping for identity {0} was to " +
                           "node {1} which has failed so task {2} will " +
                           "run locally", identity.getName(),
                           handoffNode.getId(), objName);
            }
            return false;
        }

        long newNodeId = handoffNode.getId();
        if (newNodeId == nodeId) {
            // a timing issue caused us to try handing-off to ourselves, so
            // just return from here
            return false;
        }
View Full Code Here

        }
        public void run() {
      System.err.println("Get shutdown nodes (should be marked failed)");
      for (Long longId : ids) {
          long id = longId.longValue();
          Node node = watchdogService.getNode(id);
          System.err.println("node (" + id + "):" +
                 (node == null ? "(removed)" : node));
          if (node == null) {
        fail("Node removed before recovery complete: " + id);
          }
          if (node.isAlive()) {
        fail("Node not marked as failed: " + id);
          }
          Node backup = watchdogService.getBackup(id);
          if (hasBackup) {
        if (backup == null) {
            fail("failed node (" + id + ") has no backup");
        } else {
            backups.add(backup);
View Full Code Here

        int getNumNotifications() {
            return notifications;
        }

        Node getLastNotification() {
            Node node = lastNode;
            lastNode = null;
            return node;
        }
View Full Code Here

        int numNodes;
        public void run() {
            Iterator<Node> iter = watchdogService.getNodes();
            numNodes = 0;
            while (iter.hasNext()) {
                Node node = iter.next();
                System.err.println(node);
                numNodes++;
            }
        }
View Full Code Here

        for (SgsTestNode node : additionalNodes) {
            final long id = node.getDataService().getLocalNodeId();
            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    Node node = watchdogService.getNode(id);
                    if (node == null) {
                        fail("Expected node for ID " + id + " got " +  node);
                    }
                    System.err.println(node);
                    if (id != node.getId()) {
                        fail("Expected node ID " + id +
                                " got, " + node.getId());
                    } else if (! node.isAlive()) {
                        fail("Node " + id + " is not alive!");
                    }
                }
            }, taskOwner);
        }
View Full Code Here

    }

    @Test public void testGetNodeNonexistentNode() throws Exception {
        txnScheduler.runTask(new TestAbstractKernelRunnable() {
            public void run() throws Exception {
                Node node = watchdogService.getNode(29);
                System.err.println(node);
                if (node != null) {
                    fail("Expected null node, got " + node);
                }
            }
View Full Code Here

        addNodes(null, NUM_WATCHDOGS);
        for (SgsTestNode node : additionalNodes) {
            final long id = node.getDataService().getLocalNodeId();
            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    Node node = watchdogService.getNode(id);
                    if (node == null) {
                        fail("Expected node for ID " + id + " got " +  node);
                    }
                    System.err.println(node);
                    if (id != node.getId()) {
                        fail("Expected node ID " + id +
                                " got, " + node.getId());
                    } else if (! node.isAlive()) {
                        fail("Node " + id + " is not alive!");
                    }
                }
            }, taskOwner);
        }
        // shutdown nodes...
  if (additionalNodes != null) {
            for (SgsTestNode node : additionalNodes) {
                node.shutdown(false);
            }
            additionalNodes = null;
        }

  // wait for all nodes to fail...
  Thread.sleep(renewTime * 4);
       
  Set<Node> nodes = listener.getFailedNodes();
  System.err.println("failedNodes: " + nodes);
  if (nodes.size() != 5) {
      fail("Expected 5 failed nodes, got " + nodes.size());
  }
  for (Node node : nodes) {
      System.err.println(node);
      if (node.isAlive()) {
    fail("Node " + node.getId() + " is alive!");
      }
  }
    }
View Full Code Here

    private void checkNotification(DummyNodeListener listener, Health expected)
        throws InterruptedException
    {
        // Wait for notification to work its way through
        Thread.sleep(2000);
        Node node = listener.getLastNotification();
        if (node == null) {
            fail("Expected a notification, did not get any");
        }
        if (node.getHealth() != expected) {
            fail("Expected " + expected + ", got " + node.getHealth());
        }
    }
View Full Code Here

  System.err.println("Get shutdown nodes (should be removed)...");
        txnScheduler.runTask(new TestAbstractKernelRunnable() {
            public void run() throws Exception {
          for (Long longId : ids) {
              long id = longId.longValue();
              Node node = watchdogService.getNode(id);
              System.err.println("node (" + id + "):" +
                     (node == null ? "(removed)" : node));
              if (node != null) {
            fail("Expected node to be removed: " + node);
              }
View Full Code Here

TOP

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

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.