Package co.paralleluniverse.galaxy.cluster

Examples of co.paralleluniverse.galaxy.cluster.NodeInfo


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 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

                pipeline.addBefore("nodeNameWriter", "nodeInfoSetter", new SimpleChannelUpstreamHandler() {
                    @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

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.