Package org.jgroups

Examples of org.jgroups.Channel


   private static final String cName = "FlushWithChannelFailuresTest";
  
    @Test
    public void testAndLoop() throws Exception {
        int numChannels = 10;
        Channel channels[] = new Channel[numChannels];
        for (int j = 0; j < numChannels; j++) {
            if (j == 0) {
                channels[j] = createChannel(true, numChannels);
            } else {
                channels[j] = createChannel((JChannel) channels[0]);
View Full Code Here


    @Test
    public void testAdditionalData() throws Exception {
        for(int i=1;i <= 2;i++) {
            System.out.println("-- attempt # " + i + "/2");
            Channel c=createChannel(true);
            try {
                Map<String,Object> m=new HashMap<String,Object>();
                m.put("additional_data", new byte[] { 'b', 'e', 'l', 'a' });
                c.down(new Event(Event.CONFIG, m));
                c.connect("AddDataTest.testadditionalData()");
                UUID addr=(UUID)c.getAddress();
                System.out.println("address is " + addr);
                assert addr.getAdditionalData() != null;
                assert addr.getAdditionalData()[0] == 'b';
            }
            finally {
                c.close();
            }
        }
    }
View Full Code Here

    System.out.println("    receive message: " + msg.getObject());
  }

  public void start(String props, String name) throws Exception {
   
    Channel channel = new JChannel(props);
    channel.setReceiver(this);
   
    if(name != null) {
      channel.setName(name);
    }
   
    channel.connect("LargeStateChannel");
   
    while(true){
     
      Msg msg = new Msg(10000);
      channel.send(null, msg);
     
      System.out.println("Press Enter to re-test\n");
      System.in.read();
    }
  }
View Full Code Here

      private Set<String> caches = new HashSet<String>();
     
      LockManagerEntry(Cache<?, ?> cache)
      {
         JGroupsTransport transport = (JGroupsTransport) cache.getAdvancedCache().getRpcManager().getTransport();
         Channel channel = transport.getChannel();
        
         this.service = new CoreGroupCommunicationService();
         this.service.setChannel(channel);
         this.service.setScopeId(SCOPE_ID);
        
         try
         {
            this.service.start();
         }
         catch (Exception e)
         {
            throw new IllegalStateException("Unexpected exception while starting group communication service for " + channel.getClusterName());
         }
        
         this.lockManager = new SharedLocalYieldingClusterLockManager(SERVICE_NAME, this.service, this.service);
        
         try
         {
            this.lockManager.start();
         }
         catch (Exception e)
         {
            this.service.stop();
            throw new IllegalStateException("Unexpected exception while starting lock manager for " + channel.getClusterName());
         }
      }
View Full Code Here

    private void start(String props, String stack_name) throws Exception {
        factory=new JChannelFactory();
        factory.setMultiplexerConfig(props);

        final Channel ch1, ch2;
        ch1=factory.createMultiplexerChannel(stack_name, "id-1");
        Draw draw1=new Draw(ch1);
        ch1.connect("bela");

        ch2=factory.createMultiplexerChannel(stack_name, "id-2");
        Draw draw2=new Draw(ch2);
        ch2.connect("ban");
View Full Code Here

      return names;
   }
  
   protected Channel createChannel(Object id) throws Exception
   {
      Channel c = null;
      if (isMuxChannelUsed())
      {
         for (int i = 0; i < muxFactory.length; i++)
         {
            if (!muxFactory[i].hasMuxChannel(MUX_CHANNEL_CONFIG_STACK_NAME, id.toString()))
View Full Code Here

         return createChannel(configFile, channelOptions);
      }

      protected Channel createChannel(String configFile, Map channelOptions) throws Exception
      {
         Channel ch = null;
         log.info("Using configuration file " + configFile);
         ch = new JChannel(configFile);
         for (Iterator iter = channelOptions.keySet().iterator(); iter.hasNext();)
         {
            Integer key = (Integer) iter.next();
            Object value = channelOptions.get(key);
            ch.setOpt(key.intValue(), value);
         }
         return ch;
      }
View Full Code Here

         this.f = f;        
      }

      public Channel createChannel(Object id) throws Exception
      {
         Channel c = f.createMultiplexerChannel(MUX_CHANNEL_CONFIG_STACK_NAME, id.toString());
         if(useBlocking())
         {
            c.setOpt(Channel.BLOCK, Boolean.TRUE);
         }
         Address address = c.getLocalAddress();
         String append = "[" + id + "]" + " using " + MUX_CHANNEL_CONFIG + ",stack " + MUX_CHANNEL_CONFIG_STACK_NAME;
         if (address == null)
         {
            log.info("Created unconnected mux channel " + append);
         }
View Full Code Here

      receiver.clear();
  

   protected Channel createChannel() throws ChannelException
   {
      Channel ret = new JChannel(CHANNEL_CONFIG);
      ret.setOpt(Channel.BLOCK, Boolean.TRUE);
      Protocol flush = ((JChannel) ret).getProtocolStack().findProtocol("FLUSH");
      if (flush != null)
      {
         Properties p = new Properties();
         p.setProperty("timeout", "0");
View Full Code Here

      }
     
      public void verify(Object verifiable)
      {
         Collection channels = (Collection) verifiable;
         Channel ch = app.getChannel();
         assertFalse("Channel open", ch.isOpen());
         assertFalse("Chnanel connected", ch.isConnected());

         //if this channel had more than one member then verify that
         //the other member does not have departed member in its view
         if (viewBeforeClose.getMembers().size() > 1)
         {
            for (Iterator iter = channels.iterator(); iter.hasNext();)
            {
               FlushTestReceiver receiver = (FlushTestReceiver) iter.next();
               Channel channel = receiver.getChannel();
               boolean pairServiceFound = (receiver.isUsingMuxChannel() && muxId.equals(((MuxChannel)channel).getId()));              
               if(pairServiceFound || !receiver.isUsingMuxChannel())
               {
                  assertTrue("Removed from view, address " + appAddress + " view is " + channel.getView(),
                     !channel.getView().getMembers().contains(appAddress));
               }
            }
         }
      }
View Full Code Here

TOP

Related Classes of org.jgroups.Channel

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.