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


            updateVote(identity, active);
    }

    /** {@inheritDoc} */
    public Node getNode(Identity identity) throws UnknownIdentityException {
        Node node = nodeMap.get(identity);
        if (node == null)
            throw new UnknownIdentityException("Identity not mapped: " +
                                               identity.getName());
        return node;
    }
View Full Code Here

        return nodeMap.containsKey(identity);
    }

    /** Returns the current mapping for the given identity, or -1. */
    public long getMapping(Identity identity) {
        Node node = nodeMap.get(identity);
        if (node == null)
            return -1;
        else
            return node.getId();
    }
View Full Code Here

    /** Assigns the given identity to the given node. */
    public static long assignIdentity(Class<?> service, Identity identity,
                                      long nodeId) {
        DummyNodeMappingService newService = serviceMap.get(nodeId);
        Node node = newService.watchdogService.getNode(nodeId);
        if (nodeMap.putIfAbsent(identity, node) == null) {
            System.out.println("adding identity: " + identity.getName());
            votes.put(identity, new AtomicLong(0));
            for (NodeMappingListener listener : newService.listeners)
                listener.mappingAdded(identity, null);
View Full Code Here

     */
    public void moveIdentity(Class<?> service, Identity identity, long nodeId) {
        if (nodeId == localId)
            return;

        Node oldNode = nodeMap.get(identity);
        if (oldNode == null)
            throw new IllegalArgumentException("Unknown identity: " +
                                               identity.getName());
        if (oldNode.getId() != localId)
            throw new IllegalArgumentException("Identity not mapped to this " +
                                               "node: " + identity.getName());

        DummyNodeMappingService newService = serviceMap.get(nodeId);
        Node newNode = watchdogService.getNode(nodeId);
        nodeMap.put(identity, newNode);
        if (service != null) {
            try {
                newService.setStatus(service, identity, true);
            } catch (UnknownIdentityException uie) {}
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.FINE)) {
                logger.logThrow(Level.FINE, 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.FINE)) {
                logger.log(Level.FINE, "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

        return getClass().getName();
    }

    /** {@inheritDoc} */
    public void ready() {
        Node node = nodeMap.get(localId);
        for (NodeListener listener : listeners)
            listener.nodeHealthUpdate(node);
    }
View Full Code Here

    /** {@inheritDoc} */
    public void shutdown() {
        health = Health.RED;
        nodeMap.remove(localId);
        Node localNode = new NodeImpl(localId);
        for (NodeListener listener : listeners)
            listener.nodeHealthUpdate(localNode);
    }
View Full Code Here

        return nodeMap.values().iterator();
    }

    /** {@inheritDoc} */
    public Node getNode(long nodeId) {
        Node node = nodeMap.get(nodeId);
        if (node == null)
            throw new IllegalArgumentException("Unknown node id: " + nodeId);
        return node;
    }
View Full Code Here

     * oldNode} to {@code newNode}.
     */
    public void moveIdentity(String name, final long oldNodeId, long newNodeId)
  throws Exception
    {
  Node oldNode = KernelCallable.call(
      new KernelCallable<Node>("getNode") {
    public Node call() {
        return watchdogService.getNode(oldNodeId);
    } },
      txnScheduler, 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.