Package org.jboss.ejb.client

Examples of org.jboss.ejb.client.ClusterContext


        if(ejbRemoteConnectorService == null || endpoint == null) {
            return;
        }
        final SocketBinding ejbRemoteConnectorSocketBinding = ejbRemoteConnectorService.getEJBRemoteConnectorSocketBinding();
        final InetAddress bindAddress = ejbRemoteConnectorSocketBinding.getAddress();
        final ClusterContext clusterContext = ejbClientContext.getOrCreateClusterContext(clusterName);
        // add the nodes to the cluster context
        for (Map.Entry<String, List<ClientMapping>> entry : addedNodes.entrySet()) {
            final String addedNodeName = entry.getKey();
            // if the current node is being added, then let the local receiver handle it
            if (LocalEjbReceiver.this.getNodeName().equals(addedNodeName)) {
                clusterContext.addClusterNodes(new LocalClusterNodeManager());
                continue;
            }
            // if the EJB client context is the default server level EJB client context
            // which can only handle local receiver and no remote receivers (due to lack of configurations
            // to connect to them), then skip that context
            if (this.isLocalOnlyEJBClientContext(ejbClientContext)) {
                logger.debug("Skipping cluster node additions to EJB client context " + ejbClientContext + " since it can only handle local node");
                continue;
            }
            // find a matching client mapping for our bind address
            final List<ClientMapping> clientMappings = entry.getValue();
            ClientMapping resolvedClientMapping = null;
            for (final ClientMapping clientMapping : clientMappings) {
                final InetAddress sourceNetworkAddress = clientMapping.getSourceNetworkAddress();
                final int netMask = clientMapping.getSourceNetworkMaskBits();
                final boolean match = NetworkUtil.belongsToNetwork(bindAddress, sourceNetworkAddress, (byte) (netMask & 0xff));
                if (match) {
                    resolvedClientMapping = clientMapping;
                    logger.debug("Client mapping " + clientMapping + " matches client address " + bindAddress);
                    break;
                }
            }
            if (resolvedClientMapping == null) {
                EjbLogger.ROOT_LOGGER.cannotAddClusterNodeDueToUnresolvableClientMapping(addedNodeName, clusterName, bindAddress);
                continue;
            }
            final ClusterNodeManager remotingClusterNodeManager = new RemotingConnectionClusterNodeManager(clusterContext, endpoint, addedNodeName, resolvedClientMapping.getDestinationAddress(), resolvedClientMapping.getDestinationPort());
            clusterContext.addClusterNodes(remotingClusterNodeManager);
        }

    }
View Full Code Here


        @Override
        public void removedEntries(Set<String> removedNodes) {
            final List<EJBReceiverContext> receiverContexts = LocalEjbReceiver.this.contexts;
            for (final EJBReceiverContext receiverContext : receiverContexts) {
                final ClusterContext clusterContext = receiverContext.getClientContext().getClusterContext(this.cluster.getName());
                if (clusterContext == null) {
                    continue;
                }
                // remove the nodes from the cluster context
                for (final String removedNodeName : removedNodes) {
                    clusterContext.removeClusterNode(removedNodeName);
                }
            }
        }
View Full Code Here

        @Override
        public void removedEntries(Map<String, List<ClientMapping>> removedNodes) {
            final List<EJBReceiverContext> receiverContexts = LocalEjbReceiver.this.contexts;
            for (final EJBReceiverContext receiverContext : receiverContexts) {
                final ClusterContext clusterContext = receiverContext.getClientContext().getClusterContext(this.cluster.getGroup().getName());
                if (clusterContext == null) {
                    continue;
                }
                // remove the nodes from the cluster context
                for (final String removedNodeName : removedNodes.keySet()) {
                    clusterContext.removeClusterNode(removedNodeName);
                }
            }
        }
View Full Code Here

        final Endpoint endpoint = this.endpointValue.getOptionalValue();
        if(ejbRemoteConnectorService == null || endpoint == null) {
            return;
        }
        final List<EJBRemoteConnectorService.EjbListenerAddress> listeningAddresses = ejbRemoteConnectorService.getListeningAddresses();
        final ClusterContext clusterContext = ejbClientContext.getOrCreateClusterContext(clusterName);
        // add the nodes to the cluster context
        for (Map.Entry<String, List<ClientMapping>> entry : addedNodes.entrySet()) {
            final String addedNodeName = entry.getKey();
            // if the current node is being added, then let the local receiver handle it
            if (LocalEjbReceiver.this.getNodeName().equals(addedNodeName)) {
                clusterContext.addClusterNodes(new LocalClusterNodeManager());
                continue;
            }
            // if the EJB client context is the default server level EJB client context
            // which can only handle local receiver and no remote receivers (due to lack of configurations
            // to connect to them), then skip that context
            if (this.isLocalOnlyEJBClientContext(ejbClientContext)) {
                logger.debugf("Skipping cluster node additions to EJB client context %s since it can only handle local node", ejbClientContext);
                continue;
            }
            // find a matching client mapping for our bind address
            final List<ClientMapping> clientMappings = entry.getValue();
            ClientMapping resolvedClientMapping = null;
            for (final ClientMapping clientMapping : clientMappings) {
                final InetAddress sourceNetworkAddress = clientMapping.getSourceNetworkAddress();
                final int netMask = clientMapping.getSourceNetworkMaskBits();
                for(EJBRemoteConnectorService.EjbListenerAddress binding : listeningAddresses) {
                    final boolean match = NetworkUtil.belongsToNetwork(binding.getAddress().getAddress(), sourceNetworkAddress, (byte) (netMask & 0xff));
                    if (match) {
                        resolvedClientMapping = clientMapping;
                        logger.debugf("Client mapping %s matches client address %s", clientMapping, binding.getAddress().getAddress());
                        break;
                    }
                }
                if(resolvedClientMapping != null) {
                    break;
                }
            }
            if (resolvedClientMapping == null) {
                EjbLogger.ROOT_LOGGER.cannotAddClusterNodeDueToUnresolvableClientMapping(addedNodeName, clusterName, listeningAddresses);
                continue;
            }
            final ClusterNodeManager remotingClusterNodeManager = new RemotingConnectionClusterNodeManager(clusterContext, endpoint, addedNodeName, resolvedClientMapping.getDestinationAddress(), resolvedClientMapping.getDestinationPort(), ejbRemoteConnectorService.getProtocol());
            clusterContext.addClusterNodes(remotingClusterNodeManager);
        }

    }
View Full Code Here

     * Waiting for getting cluster context - it could take some time for client to get info from cluster nodes
     */
    protected void waitForClusterContext() throws InterruptedException {
        int counter = 0;
        EJBClientContext ejbClientContext = EJBClientContext.requireCurrent();
        ClusterContext clusterContext = null;
        do {
            clusterContext = ejbClientContext.getClusterContext(CLUSTER_NAME);
            counter--;
            Thread.sleep(CLUSTER_ESTABLISHMENT_WAIT_MS);
        } while (clusterContext == null && counter < CLUSTER_ESTABLISHMENT_LOOP_COUNT);
View Full Code Here

    @Override
    public void registryAdded(Registry<String, List<ClientMapping>> registry) {
        final String clusterName = registry.getName();
        for (final EJBReceiverContext receiverContext : this.contexts) {
            final ClusterContext clusterContext = receiverContext.getClientContext().getOrCreateClusterContext(clusterName);
            // TODO: we currently don't take into account any nodes in the cluster for Local EJB receiver.
            // We just register the current local receiver for the cluster context which effectively means that
            // any invocations via the LocalEJBReceiver for any clusters will be pinned to the current local node.
            // We need to decide whether we want to create remote ejb receiver(s) for the cluster nodes, out of this
            // local receiver
            clusterContext.addClusterNode(this.getNodeName(), new LocalClusterNodeManager());
        }
        // TODO: We also should register a listener for listening to removed/added nodes from the cluster
    }
View Full Code Here

    @Override
    public void registryAdded(Registry<String, List<ClientMapping>> registry) {
        final String clusterName = registry.getName();
        for (final EJBReceiverContext receiverContext : this.contexts) {
            final ClusterContext clusterContext = receiverContext.getClientContext().getOrCreateClusterContext(clusterName);
            // TODO: we currently don't take into account any nodes in the cluster for Local EJB receiver.
            // We just register the current local receiver for the cluster context which effectively means that
            // any invocations via the LocalEJBReceiver for any clusters will be pinned to the current local node.
            // We need to decide whether we want to create remote ejb receiver(s) for the cluster nodes, out of this
            // local receiver
            clusterContext.addClusterNode(this.getNodeName(), new LocalClusterNodeManager());
        }
        // TODO: We also should register a listener for listening to removed/added nodes from the cluster
    }
View Full Code Here

        if(ejbRemoteConnectorService == null || endpoint == null) {
            return;
        }
        final SocketBinding ejbRemoteConnectorSocketBinding = ejbRemoteConnectorService.getEJBRemoteConnectorSocketBinding();
        final InetAddress bindAddress = ejbRemoteConnectorSocketBinding.getAddress();
        final ClusterContext clusterContext = ejbClientContext.getOrCreateClusterContext(clusterName);
        // add the nodes to the cluster context
        for (Map.Entry<String, List<ClientMapping>> entry : addedNodes.entrySet()) {
            final String addedNodeName = entry.getKey();
            // if the current node is being added, then let the local receiver handle it
            if (LocalEjbReceiver.this.getNodeName().equals(addedNodeName)) {
                clusterContext.addClusterNodes(new LocalClusterNodeManager());
                continue;
            }
            // if the EJB client context is the default server level EJB client context
            // which can only handle local receiver and no remote receivers (due to lack of configurations
            // to connect to them), then skip that context
            if (this.isLocalOnlyEJBClientContext(ejbClientContext)) {
                logger.debug("Skipping cluster node additions to EJB client context " + ejbClientContext + " since it can only handle local node");
                continue;
            }
            // find a matching client mapping for our bind address
            final List<ClientMapping> clientMappings = entry.getValue();
            ClientMapping resolvedClientMapping = null;
            for (final ClientMapping clientMapping : clientMappings) {
                final InetAddress sourceNetworkAddress = clientMapping.getSourceNetworkAddress();
                final int netMask = clientMapping.getSourceNetworkMaskBits();
                final boolean match = NetworkUtil.belongsToNetwork(bindAddress, sourceNetworkAddress, (byte) (netMask & 0xff));
                if (match) {
                    resolvedClientMapping = clientMapping;
                    logger.debug("Client mapping " + clientMapping + " matches client address " + bindAddress);
                    break;
                }
            }
            if (resolvedClientMapping == null) {
                EjbLogger.ROOT_LOGGER.cannotAddClusterNodeDueToUnresolvableClientMapping(addedNodeName, clusterName, bindAddress);
                continue;
            }
            final ClusterNodeManager remotingClusterNodeManager = new RemotingConnectionClusterNodeManager(clusterContext, endpoint, addedNodeName, resolvedClientMapping.getDestinationAddress(), resolvedClientMapping.getDestinationPort());
            clusterContext.addClusterNodes(remotingClusterNodeManager);
        }

    }
View Full Code Here

        @Override
        public void removedEntries(Set<String> removedNodes) {
            final List<EJBReceiverContext> receiverContexts = LocalEjbReceiver.this.contexts;
            for (final EJBReceiverContext receiverContext : receiverContexts) {
                final ClusterContext clusterContext = receiverContext.getClientContext().getClusterContext(this.cluster.getName());
                if (clusterContext == null) {
                    continue;
                }
                // remove the nodes from the cluster context
                for (final String removedNodeName : removedNodes) {
                    clusterContext.removeClusterNode(removedNodeName);
                }
            }
        }
View Full Code Here

        if(ejbRemoteConnectorService == null || endpoint == null) {
            return;
        }
        final SocketBinding ejbRemoteConnectorSocketBinding = ejbRemoteConnectorService.getEJBRemoteConnectorSocketBinding();
        final InetAddress bindAddress = ejbRemoteConnectorSocketBinding.getAddress();
        final ClusterContext clusterContext = ejbClientContext.getOrCreateClusterContext(clusterName);
        // add the nodes to the cluster context
        for (Map.Entry<String, List<ClientMapping>> entry : addedNodes.entrySet()) {
            final String addedNodeName = entry.getKey();
            // if the current node is being added, then let the local receiver handle it
            if (LocalEjbReceiver.this.getNodeName().equals(addedNodeName)) {
                clusterContext.addClusterNodes(new LocalClusterNodeManager());
                continue;
            }
            // if the EJB client context is the default server level EJB client context
            // which can only handle local receiver and no remote receivers (due to lack of configurations
            // to connect to them), then skip that context
            if (this.isLocalOnlyEJBClientContext(ejbClientContext)) {
                logger.debug("Skipping cluster node additions to EJB client context " + ejbClientContext + " since it can only handle local node");
                continue;
            }
            // find a matching client mapping for our bind address
            final List<ClientMapping> clientMappings = entry.getValue();
            ClientMapping resolvedClientMapping = null;
            for (final ClientMapping clientMapping : clientMappings) {
                final InetAddress sourceNetworkAddress = clientMapping.getSourceNetworkAddress();
                final int netMask = clientMapping.getSourceNetworkMaskBits();
                final boolean match = NetworkUtil.belongsToNetwork(bindAddress, sourceNetworkAddress, (byte) (netMask & 0xff));
                if (match) {
                    resolvedClientMapping = clientMapping;
                    logger.debug("Client mapping " + clientMapping + " matches client address " + bindAddress);
                    break;
                }
            }
            if (resolvedClientMapping == null) {
                EjbLogger.ROOT_LOGGER.cannotAddClusterNodeDueToUnresolvableClientMapping(addedNodeName, clusterName, bindAddress);
                continue;
            }
            final ClusterNodeManager remotingClusterNodeManager = new RemotingConnectionClusterNodeManager(clusterContext, endpoint, addedNodeName, resolvedClientMapping.getDestinationAddress(), resolvedClientMapping.getDestinationPort());
            clusterContext.addClusterNodes(remotingClusterNodeManager);
        }

    }
View Full Code Here

TOP

Related Classes of org.jboss.ejb.client.ClusterContext

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.