Package org.jgroups

Examples of org.jgroups.Channel


    * @return a reference to the DELAY instance being used by the JGroups stack
    * @throws Exception
    */
   public static DELAY setDelayForCache(Cache<?, ?> cache, int in_delay_millis, int out_delay_millis) throws Exception {
      JGroupsTransport jgt = (JGroupsTransport) TestingUtil.extractComponent(cache, Transport.class);
      Channel ch = jgt.getChannel();
      ProtocolStack ps = ch.getProtocolStack();
      DELAY delay = new DELAY();
      delay.setInDelay(in_delay_millis);
      delay.setOutDelay(out_delay_millis);
      ps.insertProtocol(delay, ProtocolStack.ABOVE, TP.class);
      return delay;
View Full Code Here


            org.jgroups.Address jgAddress = ((JGroupsAddress)cacheManager.getCoordinator()).getJGroupsAddress();
            // if jgAddress is UUID address, not the physical one, then retrieve via channel
            if (!(jgAddress instanceof IpAddress))
            {
               // this is the only way of getting physical address.
               Channel channel = transport.getChannel();
               jgAddress = (org.jgroups.Address)channel.down(new Event(Event.GET_PHYSICAL_ADDRESS, jgAddress));
            }
            if (jgAddress instanceof IpAddress)
            {
               String address = ((IpAddress)jgAddress).getIpAddress().getHostAddress();
               RSyncJob rSyncJob =
View Full Code Here

                    Set<String> extSources = config.getFederation().getExternalSources();
                    this.connectors = new Connectors(this, connectorComponents, extSources, preconfiguredProjectionsByWorkspace);                   
                    logger.debug("Loading cache '{0}' from cache container {1}", cacheName, container);
                    SchematicDb database = Schematic.get(container, cacheName);

                    Channel cacheChannel = checkClustering(database);
                    // the name of the fork stack is based on the name of the cache; this will allow multiple caches to share the
                    // same JG stack
                    String forkStackId = "modeshape-" + cacheName + "-fork-stack";
                    this.clusteringService = cacheChannel != null ? ClusteringService.startForked(forkStackId, cacheChannel) : null;
View Full Code Here

                throw (t instanceof Exception) ? (Exception)t : new RuntimeException(t);
            }
        }

        protected Channel checkClustering( SchematicDb database ) {
            Channel cacheChannel = null;
            if (database.getCache() instanceof AdvancedCache) {
                RpcManager rpcManager = ((AdvancedCache<?, ?>)database.getCache()).getRpcManager();
                if (rpcManager != null && rpcManager.getTransport() instanceof JGroupsTransport) {
                    cacheChannel = ((JGroupsTransport)rpcManager.getTransport()).getChannel();
                }
            }
            if (logger.isDebugEnabled()) {
                if (cacheChannel != null) {
                    logger.debug("ModeShape detected active Infinispan cluster '{0}' and will be started in clustered mode",
                                 cacheChannel.getClusterName());
                } else {
                    logger.debug("ModeShape could not detect an active Infinispan cluster and will be started in non-clustered mode");
                }
            }
            return cacheChannel;
View Full Code Here

            ServiceController.Mode mode = controller.getMode();
            controller.setMode(ServiceController.Mode.ACTIVE);
            try {
                ChannelFactory factory = controller.awaitValue();
                // Create a temporary channel, but don't connect it
                Channel channel = factory.createChannel(UUID.randomUUID().toString());
                try {
                    // ProtocolStack.printProtocolSpecAsXML() is very hacky and only works on an uninitialized stack
                    List<Protocol> protocols = channel.getProtocolStack().getProtocols();
                    Collections.reverse(protocols);
                    ProtocolStack stack = new ProtocolStack();
                    stack.addProtocols(protocols);
                    context.getResult().set(stack.printProtocolSpecAsXML());
                    context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
                } finally {
                    channel.close();
                }
            } finally {
                controller.setMode(mode);
            }
        } catch (Exception e) {
View Full Code Here

      return values;
   }

   public static DISCARD getDiscardForCache(Cache<?, ?> c) throws Exception {
      JGroupsTransport jgt = (JGroupsTransport) TestingUtil.extractComponent(c, Transport.class);
      Channel ch = jgt.getChannel();
      ProtocolStack ps = ch.getProtocolStack();
      DISCARD discard = new DISCARD();
      ps.insertProtocol(discard, ProtocolStack.ABOVE, TP.class);
      return discard;
   }
View Full Code Here

    * @return a reference to the DELAY instance being used by the JGroups stack
    * @throws Exception
    */
   public static DELAY setDelayForCache(Cache<?, ?> cache, int in_delay_millis, int out_delay_millis) throws Exception {
      JGroupsTransport jgt = (JGroupsTransport) TestingUtil.extractComponent(cache, Transport.class);
      Channel ch = jgt.getChannel();
      ProtocolStack ps = ch.getProtocolStack();
      DELAY delay = new DELAY();
      delay.setInDelay(in_delay_millis);
      delay.setOutDelay(out_delay_millis);
      ps.insertProtocol(delay, ProtocolStack.ABOVE, TP.class);
      return delay;
View Full Code Here

      cache1.put("k1", "v1");
      assert "v1".equals(cache1.get("k1"));

      // create a new jgroups channel that will join the cluster
      // but without attaching the Infinispan RpcDispatcher
      Channel channel2 = createJGroupsChannel(manager(0).getCacheManagerConfiguration());
      try {
         // try the put operation again
         cache1.put("k2", "v2");
         assert "v2".equals(cache1.get("k2"));

         // create a new cache, make sure it joins properly
         ConfigurationBuilder c = getDefaultClusteredCacheConfig(cacheMode, false);
         c.clustering().stateTransfer().fetchInMemoryState(true);
         EmbeddedCacheManager cm = addClusterEnabledCacheManager(new TransportFlags());
         cm.defineConfiguration(cacheName, c.build());
         Cache<String, String> cache2 = cm.getCache(cacheName);
         assert cache2.getAdvancedCache().getRpcManager().getTransport().getMembers().size() == 3;

         assert "v1".equals(cache1.get("k1"));
         assert "v2".equals(cache1.get("k2"));
         cache1.put("k1", "v1_2");
         cache2.put("k2", "v2_2");
         assert "v1_2".equals(cache1.get("k1"));
         assert "v2_2".equals(cache1.get("k2"));
      } finally {
         channel2.close();
      }
   }
View Full Code Here

      int viewId = where[0].getTransport().getViewId() + 1;
      View view = View.create(viewMembers.get(0), viewId, (org.jgroups.Address[]) viewMembers.toArray(new org.jgroups.Address[viewMembers.size()]));

      log.trace("Before installing new view:" + viewMembers);
      for (EmbeddedCacheManager ecm : where) {
         Channel c = ((JGroupsTransport) ecm.getTransport()).getChannel();
         ((GMS) c.getProtocolStack().findProtocol(GMS.class)).installView(view);
      }
   }
View Full Code Here

    * Simulates a node crash, discarding all the messages from/to this node and then stopping the caches.
    */
   protected void crashCacheManagers(EmbeddedCacheManager... cacheManagers) {
      for (EmbeddedCacheManager cm : cacheManagers) {
         JGroupsTransport t = (JGroupsTransport) cm.getGlobalComponentRegistry().getComponent(Transport.class);
         Channel channel = t.getChannel();
         try {
            DISCARD discard = new DISCARD();
            discard.setDiscardAll(true);
            channel.getProtocolStack().insertProtocol(discard, ProtocolStack.ABOVE, TP.class);
         } catch (Exception e) {
            log.warn("Problems inserting discard", e);
            throw new RuntimeException(e);
         }
         View view = View.create(channel.getAddress(), 100);
         ((GMS) channel.getProtocolStack().findProtocol(GMS.class)).installView(view);
      }
      TestingUtil.killCacheManagers(cacheManagers);
   }
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.