Package com.sun.sgs.service

Examples of com.sun.sgs.service.Node


  checkState();
        serviceStats.isLocalNodeAliveOp.report();
  if (!getIsAlive()) {
      return false;
  } else {
      Node node = NodeImpl.getNode(dataService, localNodeId);
      if (node == null || !node.isAlive()) {
    // this will call setFailedThenNotify(true)
                reportFailure(localNodeId, CLASSNAME);
    return false;
      } else {
    return true;
View Full Code Here


      }
      isAlive = false;
  }

  if (notify) {
      Node node = new NodeImpl(localNodeId, localHost, false);
      notifyNodeListeners(node);
  }

        logger.log(
      Level.SEVERE,
View Full Code Here

      for (int i = 0; i < ids.length; i++) {
    if (ids[i] == localNodeId && status[i]) {
        /* Don't notify the local node that it is alive. */
        continue;
    }
    Node node =
                        new NodeImpl(ids[i], hosts[i], status[i], backups[i]);
    notifyNodeListeners(node);
    if (!status[i] && backups[i] == localNodeId) {
        notifyRecoveryListeners(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

     * coordinator (informed of a node failure) fails before it has
     * a chance to schedule a task to remove member sessions for
     * another failed node (cascading failure during recovery).
     */
    for (long serverNodeId : channel.getMemberNodeIds()) {
        Node serverNode = watchdogService.getNode(serverNodeId);
        if (serverNode == null || !serverNode.isAlive()) {
      channel.removeSessionSet(serverNodeId);
        }
    }
      }

View Full Code Here

  /** {@inheritDoc} */
  public void run() {
      WatchdogService watchdogService =
    txnProxy.getService(WatchdogService.class);
      Node node = watchdogService.getNode(nodeId);
      isAlive = node != null && node.isAlive();
  }
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

        }
       
        serviceStats.getNodeOp.report();

        Context context = contextFactory.joinTransaction();
        Node node = context.get(id);
        logger.log(Level.FINEST, "getNode id:{0} returns {1}", id, node);
        return node;
    }
View Full Code Here

    {
        checkState();
        serviceStats.getIdentitiesOp.report();

        // Verify that the nodeId is valid.
        Node node = watchdogService.getNode(nodeId);
        if (node == null) {
            throw new UnknownNodeException("node id: " + nodeId);
        }
        IdentityIterator iter = new IdentityIterator(dataService, nodeId);
        logger.log(Level.FINEST, "getIdentities successful");
View Full Code Here

        }
       
        public Node get(Identity identity) throws UnknownIdentityException {
            assert identity != null;
            // Check the cache
            Node node = idcache.get(identity);
            if (node != null) {
                return node;
            }
           
      String key = NodeMapUtil.getIdentityKey(identity);
      try {               
    IdentityMO idmo =
        (IdentityMO) dataService.getServiceBinding(key);
                node = watchdogService.getNode(idmo.getNodeId());
                if (node == null) {
                    // The identity is on a failed node, where the node has
                    // been removed from the data store but the identity hasn't
                    // yet.
                    throw new UnknownIdentityException("id: " + identity);
                }
                Node old = idcache.put(identity, node);
                assert (old == null);
                return node;
      } catch (NameNotBoundException e) {
                throw new UnknownIdentityException("id: " + identity);
      } catch (ObjectNotFoundException e1) {
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.