Package org.jgroups.protocols.relay

Examples of org.jgroups.protocols.relay.RELAY2$Relay2Header


                        return channel;
                    }
                };
                bridges.put(clusterName, bridge);
            }
            RELAY2 relay = new RELAY2().site(localSite);
            for (String site: sites) {
                RelayConfig.SiteConfig siteConfig = new RelayConfig.SiteConfig(site);
                relay.addSite(site, siteConfig);
                if (site.equals(localSite)) {
                    for (RelayConfig.BridgeConfig bridge: bridges.values()) {
                        siteConfig.addBridge(bridge);
                    }
                }
            }
            Configurator.resolveAndAssignFields(relay, relayConfig.getProperties());
            Configurator.resolveAndInvokePropertyMethods(relay, relayConfig.getProperties());
            stack.addProtocol(relay);
            relay.init();
        }

        // Add implicit FORK to the top of the stack
        FORK fork = new FORK();
        stack.addProtocol(fork);
View Full Code Here


      }
      if (list.size() == 0) {
         log.info("No JGroups channels available");
         return list;
      }
      RELAY2 relay = (RELAY2) list.get(0).getProtocolStack().findProtocol(RELAY2.class);
      if (relay != null) {
         try {
            Field relayerField = RELAY2.class.getDeclaredField("relayer");
            relayerField.setAccessible(true);
            Relayer relayer = (Relayer) relayerField.get(relay);
View Full Code Here

                        return channel;
                    }
                };
                bridges.put(clusterName, bridge);
            }
            RELAY2 relay = new RELAY2().site(localSite);
            for (String site: sites) {
                RelayConfig.SiteConfig siteConfig = new RelayConfig.SiteConfig(site);
                relay.addSite(site, siteConfig);
                if (site.equals(localSite)) {
                    for (RelayConfig.BridgeConfig bridge: bridges.values()) {
                        siteConfig.addBridge(bridge);
                    }
                }
            }
            Configurator.resolveAndAssignFields(relay, relayConfig.getProperties());
            Configurator.resolveAndInvokePropertyMethods(relay, relayConfig.getProperties());
            stack.addProtocol(relay);
            relay.init();
        }

        // Add implicit FORK to the top of the stack
        FORK fork = new FORK();
        stack.addProtocol(fork);
View Full Code Here

                };
                bridges.put(clusterName, bridge);
            }
            // Acquire consistent order of sites
            Collections.sort(sites);
            final RELAY2 relay = new RELAY2().site(localSite);
            for (short i = 0; i < sites.size(); ++i) {
                final String site = sites.get(i);
                RelayConfig.SiteConfig siteConfig = new RelayConfig.SiteConfig(site);
                relay.addSite(site, siteConfig);
                if (site.equals(localSite)) {
                    for (RelayConfig.BridgeConfig bridge: bridges.values()) {
                        siteConfig.addBridge(bridge);
                    }
                }
            }
            Configurator.resolveAndAssignFields(relay, relayConfig.getProperties());
            Configurator.resolveAndInvokePropertyMethods(relay, relayConfig.getProperties());
            channel.getProtocolStack().addProtocol(relay);
            relay.init();
        }

        // Handle the Sasl protocol
        final SaslConfiguration saslConfig = this.configuration.getSasl();
        if (saslConfig != null) {
View Full Code Here

                };
                bridges.put(clusterName, bridge);
            }
            // Acquire consistent order of sites
            Collections.sort(sites);
            final RELAY2 relay = new RELAY2().site(localSite);
            for (short i = 0; i < sites.size(); ++i) {
                final String site = sites.get(i);
                RelayConfig.SiteConfig siteConfig = new RelayConfig.SiteConfig(site);
                relay.addSite(site, siteConfig);
                if (site.equals(localSite)) {
                    for (RelayConfig.BridgeConfig bridge: bridges.values()) {
                        siteConfig.addBridge(bridge);
                    }
                }
            }
            Configurator.resolveAndAssignFields(relay, relayConfig.getProperties());
            Configurator.resolveAndInvokePropertyMethods(relay, relayConfig.getProperties());
            channel.getProtocolStack().addProtocol(relay);
            relay.init();
        }

        channel.setName(this.configuration.getEnvironment().getNodeName() + "/" + id);

        TransportConfiguration.Topology topology = this.configuration.getTransport().getTopology();
View Full Code Here

        a=new JChannel();
        a.connect(SFO_CLUSTER);
        System.out.println("Channel " + a.getName() + " is connected. View: " + a.getView());

        // 3- Add RELAY2 protocol to the already connected channel.
        RELAY2 relayToInject = createRELAY2(SFO);
        // Util.setField(Util.getField(relayToInject.getClass(), "local_addr"), relayToInject, a.getAddress());

        a.getProtocolStack().insertProtocolAtTop(relayToInject);
        relayToInject.down(new Event(Event.SET_LOCAL_ADDRESS, a.getAddress()));
        relayToInject.setProtocolStack(a.getProtocolStack());
        relayToInject.configure();
        relayToInject.handleView(a.getView());

        // 4- Check RELAY2 presence.
        RELAY2 ar=(RELAY2)a.getProtocolStack().findProtocol(RELAY2.class);
        assert ar != null;

        waitUntilRoute(SFO, true, 10000, 500, a);

        assert !ar.printRoutes().equals("n/a (not site master)") : "This member should be site master";

        Relayer.Route route=getRoute(a, SFO);
        System.out.println("Route at sfo to sfo: " + route);
        assert route != null;
    }
View Full Code Here

        Util.waitUntilAllChannelsHaveSameSize(30000, 1000, a,b);

        x=createNode(SFO, "X", SFO_CLUSTER, null);
        assert x.getView().size() == 1;

        RELAY2 ar=(RELAY2)a.getProtocolStack().findProtocol(RELAY2.class),
          xr=(RELAY2)x.getProtocolStack().findProtocol(RELAY2.class);

        assert ar != null && xr != null;

        JChannel a_bridge=null, x_bridge=null;
        for(int i=0; i < 20; i++) {
            a_bridge=ar.getBridge(SFO);
            x_bridge=xr.getBridge(LON);
            if(a_bridge != null && x_bridge != null && a_bridge.getView().size() == 2 && x_bridge.getView().size() == 2)
                break;
            Util.sleep(500);
        }
View Full Code Here

    }



    protected RELAY2 createRELAY2(String site_name) {
        RELAY2 relay=new RELAY2().site(site_name).enableAddressTagging(false).asyncRelayCreation(false);

        RelayConfig.SiteConfig lon_cfg=new RelayConfig.SiteConfig(LON),
          sfo_cfg=new RelayConfig.SiteConfig(SFO);

        lon_cfg.addBridge(new RelayConfig.ProgrammaticBridgeConfig(BRIDGE_CLUSTER, createBridgeStack()));
        sfo_cfg.addBridge(new RelayConfig.ProgrammaticBridgeConfig(BRIDGE_CLUSTER, createBridgeStack()));
        relay.addSite(LON, lon_cfg).addSite(SFO, sfo_cfg);
        return relay;
    }
View Full Code Here

        long deadline=System.currentTimeMillis() + timeout;

        while(System.currentTimeMillis() < deadline) {
            boolean views_correct=true;
            for(JChannel ch: channels) {
                RELAY2 relay=(RELAY2)ch.getProtocolStack().findProtocol(RELAY2.class);
                View bridge_view=relay.getBridgeView(BRIDGE_CLUSTER);
                if(bridge_view == null || bridge_view.size() != expected_size) {
                    views_correct=false;
                    break;
                }
            }
            if(views_correct)
                break;
            Util.sleep(interval);
        }

        System.out.println("Bridge views:\n");
        for(JChannel ch: channels) {
            RELAY2 relay=(RELAY2)ch.getProtocolStack().findProtocol(RELAY2.class);
            View bridge_view=relay.getBridgeView(BRIDGE_CLUSTER);
            System.out.println(ch.getAddress() + ": " + bridge_view);
        }

        for(JChannel ch: channels) {
            RELAY2 relay=(RELAY2)ch.getProtocolStack().findProtocol(RELAY2.class);
            View bridge_view=relay.getBridgeView(BRIDGE_CLUSTER);
            assert bridge_view != null && bridge_view.size() == expected_size
              : ch.getAddress() + ": bridge view=" + bridge_view + ", expected=" + expected_size;
        }
    }
View Full Code Here

    }


    protected void waitUntilRoute(String site_name, boolean present,
                                  long timeout, long interval, JChannel ch) throws Exception {
        RELAY2 relay=(RELAY2)ch.getProtocolStack().findProtocol(RELAY2.class);
        if(relay == null)
            throw new IllegalArgumentException("Protocol RELAY2 not found");
        Relayer.Route route=null;
        long deadline=System.currentTimeMillis() + timeout;
        while(System.currentTimeMillis() < deadline) {
            route=relay.getRoute(site_name);
            if((route != null && present) || (route == null && !present))
                break;
            Util.sleep(interval);
        }
        assert (route != null && present) || (route == null && !present);
View Full Code Here

TOP

Related Classes of org.jgroups.protocols.relay.RELAY2$Relay2Header

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.