Java Code Examples for com.gemstone.gemfire.cache.Region#SEPARATOR

The following examples show how to use com.gemstone.gemfire.cache.Region#SEPARATOR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VerifyUpdatesFromNonInterestEndPointDUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void acquireConnectionsAndPut(Integer port)
{
  try {
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    String poolName = r1.getAttributes().getPoolName();
    assertNotNull(poolName);
    PoolImpl pool = (PoolImpl)PoolManager.find(poolName);
    assertNotNull(pool);
    Connection conn1 = pool.acquireConnection();
    Connection conn2 = pool.acquireConnection();
    ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
    // put on a connection which is is not interest list ep
    if(conn1.getServer().getPort() == port.intValue() ){
      srp.putOnForTestsOnly(conn1, "key-1", "server-value1", new EventID(new byte[] { 1 },1,1),null);
      srp.putOnForTestsOnly(conn1, "key-2", "server-value2", new EventID(new byte[] { 1 },1,2),null);
    }
    else if(conn2.getServer().getPort() == port.intValue()){
      srp.putOnForTestsOnly(conn2, "key-1", "server-value1", new EventID(new byte[] { 1 },1,1),null);
      srp.putOnForTestsOnly(conn2, "key-2", "server-value2", new EventID(new byte[] { 1 },1,2),null);
    }
  }
  catch (Exception ex) {
    fail("while setting acquireConnections  "+ ex);
  }
}
 
Example 2
Source File: DestroyEntryPropagationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void acquireConnectionsAndDestroyEntriesK1andK2()
{
  try {
    Region r1 = cache.getRegion(Region.SEPARATOR+REGION_NAME);
    assertNotNull(r1);
    String poolName = r1.getAttributes().getPoolName();
    assertNotNull(poolName);
    PoolImpl pool = (PoolImpl)PoolManager.find(poolName);
    assertNotNull(pool);
    Connection conn = pool.acquireConnection();
    final Connection conn1;
    if (conn.getServer().getPort() != PORT2) {
      conn1 = pool.acquireConnection(); // Ensure we have a server with the proper port
    } else {
      conn1 = conn;
    }
    assertNotNull(conn1);
    assertEquals(PORT2, conn1.getServer().getPort());
    ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR+REGION_NAME, pool);
    srp.destroyOnForTestsOnly(conn1, "key1", null, Operation.DESTROY, new EntryEventImpl(new EventID(new byte[] {1},100000,1)), null);
    srp.destroyOnForTestsOnly(conn1, "key2", null, Operation.DESTROY, new EntryEventImpl(new EventID(new byte[] {1},100000,2)), null);
  }
  catch (Exception ex) {
    throw new TestException("Failed while setting acquireConnectionsAndDestroyEntry  ", ex);
  }
}
 
Example 3
Source File: UpdatePropagationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void acquireConnectionsAndPutonK1andK2(String host)
{
  try {
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    assertNotNull(r1);
    String poolName = r1.getAttributes().getPoolName();
    assertNotNull(poolName);
    PoolImpl pool = (PoolImpl)PoolManager.find(poolName);
    assertNotNull(pool);

    Connection conn = pool.acquireConnection(new ServerLocation(host,PORT1));
    assertNotNull(conn);
    assertEquals(PORT1, conn.getServer().getPort());
    ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR+ REGION_NAME, pool);
    srp.putOnForTestsOnly(conn, "key1", "server-value1", new EventID(new byte[] {1},159632,1), null);
    srp.putOnForTestsOnly(conn, "key2", "server-value2", new EventID(new byte[] {1},159632,2), null);
  }
  catch (Exception ex) {
    fail("while setting acquireConnections  " + ex);
  }
}
 
Example 4
Source File: ClearPropagationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void acquireConnectionsAndDestroyRegion(String host)
{
  try {
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    assertNotNull(r1);
    String poolName = r1.getAttributes().getPoolName();
    assertNotNull(poolName);
    PoolImpl pool = (PoolImpl)PoolManager.find(poolName);
    assertNotNull(pool);
    Connection conn1 = pool.acquireConnection(new ServerLocation(host, PORT2));
    assertNotNull(conn1);
    assertEquals(PORT2, conn1.getServer().getPort());
    ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
    srp.destroyRegionOnForTestsOnly(conn1, new EventID(new byte[] {1}, 1, 1), null);
  }
  catch (Exception ex) {
    ex.printStackTrace();
    fail("while setting acquireConnections  " + ex);
  }
}
 
Example 5
Source File: EventIdOptimizationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Generates events having specific values of threadId and sequenceId, via
 * clearRegionOperation through connection object
 * 
 * @throws Exception -
 *           thrown if any problem occurs in clearRegionOperation
 */
public static void generateEventsByClearRegionOperation() throws Exception
{
  Connection connection = pool.acquireConnection();
  String regionName = Region.SEPARATOR + REGION_NAME;
  ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);

  for (int i = 0; i < eventIds.length; i++) {
    srp.clearOnForTestsOnly(connection, eventIds[i], null);
  }
  srp.clearOnForTestsOnly(connection, eventIdForLastKey, null);
}
 
Example 6
Source File: PartitionedRegionHelper.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static String getBucketFullPath(String prFullPath, int bucketId) {
  String name = getBucketName(prFullPath, bucketId);
  if (name != null)
    return Region.SEPARATOR + PR_ROOT_REGION_NAME + Region.SEPARATOR + name;
  
  return null;
  
}
 
Example 7
Source File: HABug36773DUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void acquireConnectionsAndPut(Integer portNumber)
{
  try {
    int port = portNumber.intValue();
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    assertNotNull(r1);
    PoolImpl pool = (PoolImpl)PoolManager.find(r1.getAttributes().getPoolName());
    assertNotNull(pool);
    Connection conn = pool.acquireConnection();
    final Connection conn1;
    ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);

    if (conn.getServer().getPort() != port) {
      conn1 = pool.acquireConnection(); // Ensure we have a server
      // with the
      // proper port
    }
    else {
      conn1 = conn;
    }
    assertNotNull(conn1);
    if (port == PORT2) {
      assertEquals(PORT2, conn1.getServer().getPort());
      srp.putOnForTestsOnly(conn1, KEY1, VALUE1, new EventID(new byte[] { 1 }, 2, 1), null);
    }
    else if (port == PORT1) {
      assertEquals(PORT1, conn1.getServer().getPort());
      srp.putOnForTestsOnly(conn1, KEY2, VALUE2, new EventID(new byte[] { 1 }, 2, 2), null);
    }
    else {
      fail("Invalid ports ");
    }
  }
  catch (Exception ex) {
    ex.printStackTrace();
    fail("while setting acquireConnections  " + ex);
  }
}
 
Example 8
Source File: HABug36773DUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void acquireConnectionsAndPut(Integer portNumber)
{
  try {
    int port = portNumber.intValue();
    Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
    assertNotNull(r1);
    PoolImpl pool = (PoolImpl)PoolManager.find(r1.getAttributes().getPoolName());
    assertNotNull(pool);
    Connection conn = pool.acquireConnection();
    final Connection conn1;
    ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);

    if (conn.getServer().getPort() != port) {
      conn1 = pool.acquireConnection(); // Ensure we have a server
      // with the
      // proper port
    }
    else {
      conn1 = conn;
    }
    assertNotNull(conn1);
    if (port == PORT2) {
      assertEquals(PORT2, conn1.getServer().getPort());
      srp.putOnForTestsOnly(conn1, KEY1, VALUE1, new EventID(new byte[] { 1 }, 2, 1), null);
    }
    else if (port == PORT1) {
      assertEquals(PORT1, conn1.getServer().getPort());
      srp.putOnForTestsOnly(conn1, KEY2, VALUE2, new EventID(new byte[] { 1 }, 2, 2), null);
    }
    else {
      fail("Invalid ports ");
    }
  }
  catch (Exception ex) {
    ex.printStackTrace();
    fail("while setting acquireConnections  " + ex);
  }
}
 
Example 9
Source File: EventIdOptimizationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Generates events having specific values of threadId and sequenceId, via
 * destroyEntry operation through connection object
 * 
 * @throws Exception -
 *           thrown if any problem occurs in destroyEntry operation
 */
public static void generateEventsByDestroyEntryOperation() throws Exception
{
  Connection connection = pool.acquireConnection();
  String regionName = Region.SEPARATOR + REGION_NAME;
  ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);

  for (int i = 0; i < eventIds.length; i++) {
    srp.destroyOnForTestsOnly(connection, "KEY-" + i, null, Operation.DESTROY, new EntryEventImpl(eventIds[i]), null);
  }
  srp.destroyOnForTestsOnly(connection, LAST_KEY, null, Operation.DESTROY, new EntryEventImpl(eventIdForLastKey), null);
}
 
Example 10
Source File: PartitionedRegionHelper.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static String getBucketFullPath(String prFullPath, int bucketId) {
  String name = getBucketName(prFullPath, bucketId);
  if (name != null)
    return Region.SEPARATOR + PR_ROOT_REGION_NAME + Region.SEPARATOR + name;
  
  return null;
  
}
 
Example 11
Source File: CreateRegionExecutor.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected String getAlreadyExistingRegionForMode(String mode) {
  List<String> regionList = RegionEvents.getAllRegions();
  if(mode.contains("override-disk")){
    regionList = filterOnlyDiskRegions(regionList);
  }else if (mode.contains("skip-if-exists")){
    regionList = filterOnlyHydraTemplateRegions(regionList);
  }else if (mode.contains("override-pr")){
   if(mode.contains("colocated-with")){
     return Region.SEPARATOR + COLOCATED_ROOT_REGION;
   }else{
     regionList = filterOnlyPartitionedRegions(regionList);
   }
  }    
  return HydraUtil.getRandomElement(regionList);
}
 
Example 12
Source File: Bug36853EventsExpiryDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * First generates some events, then waits for the time equal to that of
 * delayed start of the dispatcher and then does put on the last key for few
 * iterations. The idea is to let the events added, before waiting, to expire
 * before the dispatcher to pick them up and then do a put on a LAST_KEY
 * couple of times so that atleast one of these is dispatched to client and
 * when client recieves this in the listener, the test is notified to proceed
 * for validation.
 * 
 * @throws Exception -
 *           thrown if any problem occurs in put operation
 */
public static void generateEvents() throws Exception
{
  String regionName = Region.SEPARATOR + REGION_NAME;
  Region region = cache.getRegion(regionName);
  for (int i = 0; i < TOTAL_PUTS; i++) {

    region.put("key" + i, "val-" + i);
  }
  Thread.sleep(DISPATCHER_SLOWSTART_TIME + 1000);
  for (int i = 0; i < 25; i++) {

    region.put(LAST_KEY, "LAST_VALUE");
  }
}
 
Example 13
Source File: EventIdOptimizationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Generates events having specific values of threadId and sequenceId, via
 * clearRegionOperation through connection object
 * 
 * @throws Exception -
 *           thrown if any problem occurs in clearRegionOperation
 */
public static void generateEventsByClearRegionOperation() throws Exception
{
  Connection connection = pool.acquireConnection();
  String regionName = Region.SEPARATOR + REGION_NAME;
  ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);

  for (int i = 0; i < eventIds.length; i++) {
    srp.clearOnForTestsOnly(connection, eventIds[i], null);
  }
  srp.clearOnForTestsOnly(connection, eventIdForLastKey, null);
}
 
Example 14
Source File: EventIdOptimizationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Generates events having specific values of threadId and sequenceId, via
 * destroyEntry operation through connection object
 * 
 * @throws Exception -
 *           thrown if any problem occurs in destroyEntry operation
 */
public static void generateEventsByDestroyEntryOperation() throws Exception
{
  Connection connection = pool.acquireConnection();
  String regionName = Region.SEPARATOR + REGION_NAME;
  ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);

  for (int i = 0; i < eventIds.length; i++) {
    srp.destroyOnForTestsOnly(connection, "KEY-" + i, null, Operation.DESTROY, new EntryEventImpl(eventIds[i]), null);
  }
  srp.destroyOnForTestsOnly(connection, LAST_KEY, null, Operation.DESTROY, new EntryEventImpl(eventIdForLastKey), null);
}
 
Example 15
Source File: EventIdOptimizationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Generates events having specific values of threadId and sequenceId, via put
 * operation through connection object
 * 
 * @throws Exception -
 *           thrown if any problem occurs in put operation
 */
public static void generateEventsByPutOperation() throws Exception
{
  Connection connection = pool.acquireConnection();
  String regionName = Region.SEPARATOR + REGION_NAME;
  ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);

  for (int i = 0; i < eventIds.length; i++) {
    srp.putOnForTestsOnly(connection, "KEY-" + i, "VAL-" + i, eventIds[i], null);
  }
  srp.putOnForTestsOnly(connection, LAST_KEY, "LAST_VAL", eventIdForLastKey, null);
}
 
Example 16
Source File: HADispatcherDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private static void createCQ(){
  QueryService cqService = null;
  try {
    cqService = cache.getQueryService();
  } catch (Exception cqe) {
    cqe.printStackTrace();
    fail("Failed to getCQService.");
  }
  
  // Create CQ Attributes.
  CqAttributesFactory cqf = new CqAttributesFactory();
  CqListener[] cqListeners = {new CqQueryTestListener(getLogWriter())};    
  cqf.initCqListeners(cqListeners);
  CqAttributes cqa = cqf.create();
  
  String cqName = "CQForHARegionQueueTest";
  String queryStr = "Select * from " + Region.SEPARATOR + REGION_NAME;
  
  // Create CQ.
  try {
    CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa);
    cq1.execute();
  } catch (Exception ex){
    getLogWriter().info("CQService is :" + cqService);
    ex.printStackTrace();
    AssertionError err = new AssertionError("Failed to create/execute CQ " + cqName + " . ");
    err.initCause(ex);
    throw err;
  }
}
 
Example 17
Source File: EventIdOptimizationDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Generates events having specific values of threadId and sequenceId, via put
 * operation through connection object
 * 
 * @throws Exception -
 *           thrown if any problem occurs in put operation
 */
public static void generateEventsByPutOperation() throws Exception
{
  Connection connection = pool.acquireConnection();
  String regionName = Region.SEPARATOR + REGION_NAME;
  ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);

  for (int i = 0; i < eventIds.length; i++) {
    srp.putOnForTestsOnly(connection, "KEY-" + i, "VAL-" + i, eventIds[i], null);
  }
  srp.putOnForTestsOnly(connection, LAST_KEY, "LAST_VAL", eventIdForLastKey, null);
}
 
Example 18
Source File: AbstractTestCommandExecutor.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
protected String getNewRegion(String prefix) {
  long regionNum = CLIBlackboard.getBB().getSharedCounters().incrementAndRead(CLIBlackboard.REGION_COUNTER);        
  return Region.SEPARATOR + prefix +"_" + regionNum;
}
 
Example 19
Source File: AbstractTestCommandExecutor.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
protected String getNewRegion(String prefix) {
  long regionNum = CLIBlackboard.getBB().getSharedCounters().incrementAndRead(CLIBlackboard.REGION_COUNTER);        
  return Region.SEPARATOR + prefix +"_" + regionNum;
}
 
Example 20
Source File: ParallelQueueRemovalMessage.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
@Override
protected void process(DistributionManager dm) {
  final GemFireCacheImpl cache;
  cache = GemFireCacheImpl.getInstance();
  if (cache != null) {
    final LogWriterI18n logger = cache.getLoggerI18n();
    int oldLevel = LocalRegion
        .setThreadInitLevelRequirement(LocalRegion.BEFORE_INITIAL_IMAGE);
    try {
      for (Object name : regionToDispatchedKeysMap.keySet()) {
        final String regionName = (String)name;
        final PartitionedRegion region = (PartitionedRegion)cache
            .getRegion(regionName);
        if (region == null) {
          continue;
        }
        else {
          AbstractGatewaySender abstractSender = region.getParallelGatewaySender(); 
          // Find the map: bucketId to dispatchedKeys
          // Find the bucket
          // Destroy the keys
          Map bucketIdToDispatchedKeys = (Map)this.regionToDispatchedKeysMap
              .get(regionName);
          for (Object bId : bucketIdToDispatchedKeys.keySet()) {
            final String bucketFullPath = Region.SEPARATOR
                + PartitionedRegionHelper.PR_ROOT_REGION_NAME
                + Region.SEPARATOR + region.getBucketName((Integer)bId);
            AbstractBucketRegionQueue brq = (AbstractBucketRegionQueue)cache
                .getRegionByPath(bucketFullPath, false);
            if (logger.fineEnabled()) {
              logger
                  .fine("ParallelQueueRemovalMessage : The bucket in the cache is "
                      + " bucketRegionName : "
                      + bucketFullPath
                      + " bucket: "
                      + brq);
            }

            List dispatchedKeys = (List)bucketIdToDispatchedKeys
                .get((Integer)bId);
            if (dispatchedKeys != null) {
              for (Object key : dispatchedKeys) {
                //First, clear the Event from tempQueueEvents at AbstractGatewaySender level, if exists
                //synchronize on AbstractGatewaySender.queuedEventsSync while doing so
                abstractSender.removeFromTempQueueEvents(key);
                
                if (brq != null) {
                  if (brq.isInitialized()) {
                    if (logger.fineEnabled()) {
                      logger.fine("ParallelQueueRemovalMessage : The bucket "
                          + bucketFullPath
                          + " is initialized. Destroying the key " + key
                          + " from BucketRegionQueue.");
                    }
                    destroyKeyFromBucketQueue(brq, key, region);
                  }
                  else {
                    if (logger.fineEnabled()) {
                      logger.fine("ParallelQueueRemovalMessage : The bucket "
                          + bucketFullPath + " is not yet initialized.");
                    }
                    brq.getInitializationLock().readLock().lock();
                    try {
                      if (brq.containsKey(key)) {
                        destroyKeyFromBucketQueue(brq, key, region);
                      }
                      else {
                        // if BucketRegionQueue does not have the key, it
                        // should be in tempQueue
                        // remove it from there..defect #49196
                        destroyFromTempQueue(brq.getPartitionedRegion(),
                            (Integer) bId,
                            key);
                      }
                    }
                    finally {
                      brq.getInitializationLock().readLock().unlock();
                    }
                  }
                }
                else {// brq is null. Destroy the event from tempQueue. Defect #49196
                  destroyFromTempQueue(region, (Integer) bId, key);
                }
              }
            }
          }
        }
      } //for loop regionToDispatchedKeysMap.keySet()
    } finally {
      LocalRegion.setThreadInitLevelRequirement(oldLevel);
    }
  } // cache != null
}