当前位置: 首页>>代码示例>>Java>>正文


Java Cache.addGatewayHub方法代码示例

本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.addGatewayHub方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.addGatewayHub方法的具体用法?Java Cache.addGatewayHub怎么用?Java Cache.addGatewayHub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.gemstone.gemfire.cache.Cache的用法示例。


在下文中一共展示了Cache.addGatewayHub方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateDummyGatewayHub

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
 * Generates a dummy GatewayHub (and underlying Gateways) from the given cache and gateway configurations
 */
private static void generateDummyGatewayHub(Cache dummyCache, String gatewayHubConfig, String fn) {

  if (gatewayHubConfig != null) {
    // create and configure the dummy gatewayHub
    log("Adding dummy gateway hub from config: " + gatewayHubConfig);
    GatewayHubDescription ghd = GatewayHubHelper.getGatewayHubDescription(gatewayHubConfig);

    String id = GatewayHubHelper.getId(ghd);
    int port = GatewayHubHelper.getPort(ghd, id);
    GatewayHub dummyGatewayHub = dummyCache.addGatewayHub(id, port);
    ghd.configure(dummyGatewayHub);
    log("Added dummy gateway hub: " + GatewayHubHelper.gatewayHubToString(dummyGatewayHub));

    // save the gateway hub config for future reference
    XmlGatewayHubConfigs.put(fn, gatewayHubConfig);
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:21,代码来源:CacheHelper.java

示例2: setupHubAndAddGateway

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void setupHubAndAddGateway(String site, String hub,
    Integer hubEP, String gateway, Integer gatewayEP, Boolean expectException) {

  try {
    Cache cache = CacheFactory.getAnyInstance();
    GatewayHub gatewayhub = cache.addGatewayHub(hub, hubEP.intValue());
    gatewayhub.setSocketBufferSize(25600);
    Gateway tmpgateway = gatewayhub.addGateway(gateway);
    setDiskStoreForGateway(cache, gateway, tmpgateway.getQueueAttributes());

    tmpgateway.addEndpoint(site, 
                           DistributedTestCase.getIPLiteral(), 
                           gatewayEP.intValue());
    gatewayhub.start();
    tmpgateway.start();
    if (expectException.equals(Boolean.TRUE)) {
      fail("Exception was expected while starting the gateway hub and gateway");
    }
  }
  catch (Exception ex) {
    if (expectException.equals(Boolean.FALSE)) {
      fail("While starting the gateway hub and gateway", ex);
    }
    else {
      getLogWriter().info(
          "setupHubAndAddGateway - was an expected exception, msg = "
              + ex.getMessage() + ", exception = " + expectException);
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:31,代码来源:WanAuthenticationDUnitTest.java

示例3: createWANReceiver

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void createWANReceiver(VM vm, final int wanPort) {
    SerializableCallable createSystem = new SerializableCallable() {
      public Object call() throws Exception {
        Cache cache = getCache();
        //Force the creation of the PDX registry
//        region1.put("hello", new SimpleClass(1, (byte)1));
        GatewayHub hub = cache.addGatewayHub("myId", wanPort);
        hub.start();
        return null;
      }
    };
    vm.invoke(createSystem);
  }
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:14,代码来源:PDXWanDUnitTest.java

示例4: createWANSender

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void createWANSender(VM vm, final int wanPort) {
  SerializableCallable createSystem = new SerializableCallable() {
    public Object call() throws Exception {
      Cache cache = getCache();
      GatewayHub hub = cache.addGatewayHub("myId", -1);
      Gateway gateway = hub.addGateway("g1");
      gateway.setQueueAttributes(new GatewayQueueAttributes(null, 10, 2, 1000, false, false, 5));
      gateway.addEndpoint("myid", "localhost", wanPort);
      hub.start();
      gateway.start();
      return null;
    }
  };
  vm.invoke(createSystem);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:16,代码来源:PDXWanDUnitTest.java

示例5: createPersistentGatewayAsync

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected AsyncInvocation createPersistentGatewayAsync(final VM vm, final int destinationPort) {
  SerializableRunnable createRegion = new SerializableRunnable("Create gateway region") {
    public void run() {
      Cache cache = getCache();
      RegionFactory rf = new RegionFactory();
      rf.setDataPolicy(DataPolicy.REPLICATE);
      rf.setScope(Scope.DISTRIBUTED_ACK);
      rf.setEnableGateway(true);
      rf.create(REGION_NAME);
      int port = AvailablePortHelper.getRandomAvailableTCPPort();
      GatewayHub hub = cache.addGatewayHub("h1", port);
      Gateway gateway = hub.addGateway("g1");
      DiskStoreFactory dsf = cache.createDiskStoreFactory();
      dsf.setDiskDirs(getDiskDirs());
      dsf.setMaxOplogSize(1);
      DiskStore ds = dsf.create(REGION_NAME);
      gateway.setQueueAttributes(new GatewayQueueAttributes(ds.getName(), 5, 1, 100, false, true, 60000));
      try {
        gateway.addEndpoint("end1", InetAddress.getLocalHost().getHostAddress(), destinationPort);
        hub.start();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  };
  return vm.invokeAsync(createRegion);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:PersistentGatewayDUnitTest.java

示例6: testPdxTypesNotPassedToGateway

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testPdxTypesNotPassedToGateway() throws IOException {
  
  Properties props = new Properties();
  props.setProperty(DistributionConfig.DISTRIBUTED_SYSTEM_ID_NAME, "1");
  props.setProperty(DistributionConfig.LOCATORS_NAME, "");
  getSystem(props);
  Cache cache =getCache();
  GatewayHub hub = cache.addGatewayHub("Test Hub", -1);
  Gateway gateway = hub.addGateway("test gateway");
  gateway.setQueueAttributes(new GatewayQueueAttributes(".", 100, 1, 1, false, false, true, 15));
  final TestGatewayListener listener = new TestGatewayListener();
  gateway.addListener(listener);
  hub.start();
  gateway.start();
  Region region = cache.createRegionFactory(RegionShortcut.REPLICATE).setEnableGateway(true)
      .setGatewayHubId("Test Hub")
  .create("region");
  
  DataSerializer.writeObject(new TestPdx("a"), new NullDataOutputStream());

  region.put(new TestPdx("b"), new TestPdx("c"));
  region.put(new TestPdx("a"), new TestPdx("d"));
  
  waitForCriterion(new WaitCriterion() {
    
    public boolean done() {
      return listener.seenEvents.size() >= 2;
    }
    
    public String description() {
      return "Waiting for " + listener.seenEvents.size() + " to be 2";
    }
  }, 1000, 50, true);
  
  List<GatewayEvent> events = listener.seenEvents;
  assertEquals(2, events.size());
  assertEquals(new TestPdx("b"), events.get(0).getKey());
  assertEquals(new TestPdx("c"), events.get(0).getDeserializedValue());
  assertEquals(new TestPdx("a"), events.get(1).getKey());
  assertEquals(new TestPdx("d"), events.get(1).getDeserializedValue());
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:42,代码来源:PdxGatewayEventListenerDUnitTest.java


注:本文中的com.gemstone.gemfire.cache.Cache.addGatewayHub方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。