Package com.sun.sgs.service

Examples of com.sun.sgs.service.Node


        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


        }
        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

      WatchdogService watchdogService =
    ChannelServiceImpl.getWatchdogService();
      for (int i = 0; i < numServers; i++) {
    int tryIndex = (startIndex + i) % numServers;
    long candidateId = serverIds[tryIndex];
    Node coordCandidate = watchdogService.getNode(candidateId);
    if (coordCandidate != null && coordCandidate.isAlive()) {
        return candidateId;
    }
      }
  }
  return getLocalNodeId();
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

  System.err.println("Get live nodes...");
        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);
              if (node == null || !node.isAlive()) {
            fail("Expected alive node");
              }
          }
            }
        }, taskOwner);
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.