Package co.paralleluniverse.galaxy.cluster

Examples of co.paralleluniverse.galaxy.cluster.NodeInfo


    @Override
    public void joinedCluster() {
        super.joinedCluster();

        final NodeInfo master = getCluster().getMaster(getCluster().getMyNodeId());
        if (master != null) {
            LOG.info("Connecting to master node {}", master.getName());
            reconnect(master.getName());
        }
    }
View Full Code Here


        @Override
        public boolean add(Channel channel) {
            if (channel instanceof ServerChannel)
                return super.add(channel);
            else {
                final NodeInfo node = ChannelNodeInfo.nodeInfo.get(channel);
                if (node == null) {
                    LOG.warn("Received connection from an unknown address {}.", channel.getRemoteAddress());
                    throw new RuntimeException("Unknown node for address " + channel.getRemoteAddress());
                }
                final short nodeId = node.getNodeId();
                if (channels.containsKey(nodeId)) {
                    LOG.warn("Received connection from address {} of node {}, but this node is already connected.", channel.getRemoteAddress(), nodeId);
                    throw new RuntimeException("Node " + nodeId + " already connected.");
                }
                final boolean added = super.add(channel);
View Full Code Here

    }

    @Override
    protected void start(boolean master) {
        if (master) {
            final NodeInfo serverInfo = getCluster().getMaster(Comm.SERVER);
            if (serverInfo != null) {
                LOG.info("Came online and server found. Connecting.");
                reconnect(serverInfo.getName());
            }
        }
    }
View Full Code Here

        @Override
        public boolean add(Channel channel) {
            if (channel instanceof ServerChannel)
                return super.add(channel);
            else {
                final NodeInfo node = getNodeInfo(channel);
                if (node == null) {
                    LOG.warn("Received connection from an unknown address {}.", channel.getRemoteAddress());
                    throw new RuntimeException("Unknown node for address " + channel.getRemoteAddress());
                }
                final boolean added = super.add(channel);
View Full Code Here

public class ChannelAttachedNodeResolver extends ChannelMessageNodeResolver {
    @Override
    protected short getNodeId(ChannelHandlerContext ctx, SocketAddress address) {
        final Channel channel = ctx.getChannel();
        //final SocketAddress address = channel.getRemoteAddress();
        NodeInfo node = ChannelNodeInfo.nodeInfo.get(channel);
        assert node != null;
        return node.getNodeId();
    }
View Full Code Here

                    @Override
                    public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
                        if (nodeName == null)
                            throw new RuntimeException("nodeName not set!");
                        final NodeInfo ni = cluster.getNodeInfoByName(nodeName);
                        ChannelNodeInfo.nodeInfo.set(ctx.getChannel(), ni);
                        super.channelConnected(ctx, e);
                        pipeline.remove(this);
                    }
View Full Code Here

            packet.addMessage(m);
        return packet;
    }

    private void addNodeInfo(short node, InetSocketAddress address) {
        NodeInfo ni = mock(NodeInfo.class);
        when(ni.getNodeId()).thenReturn(node);
        when(ni.get(IpConstants.IP_ADDRESS)).thenReturn(address.getAddress());
        when(ni.get(IpConstants.IP_COMM_PORT)).thenReturn(address.getPort());

        when(cluster.getMaster(node)).thenReturn(ni);
        masters.add(ni);
    }
View Full Code Here

        verify(comm).send(captor.capture());
        return captor.getValue();
    }

    private NodeInfo makeNodeInfo(final short node) {
        return new NodeInfo() {
            @Override
            public String getName() {
                return "NODE-" + node;
            }
View Full Code Here

    @Override
    public void joinedCluster() {
        super.joinedCluster();

        final NodeInfo master = getCluster().getMaster(getCluster().getMyNodeId());
        if (master != null) {
            LOG.info("Connecting to master node {}", master.getName());
            reconnect(master.getName());
        }
    }
View Full Code Here

        @Override
        public boolean add(Channel channel) {
            if (channel instanceof ServerChannel)
                return super.add(channel);
            else {
                final NodeInfo node = getNodeInfo(channel);
                if (node == null) {
                    LOG.warn("Received connection from an unknown address {}.", channel.getRemoteAddress());
                    throw new RuntimeException("Unknown node for address " + channel.getRemoteAddress());
                }
                final boolean added = super.add(channel);
View Full Code Here

TOP

Related Classes of co.paralleluniverse.galaxy.cluster.NodeInfo

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.