Java Code Examples for com.gemstone.gemfire.cache.Region#getFullPath()

The following examples show how to use com.gemstone.gemfire.cache.Region#getFullPath() . 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: DistributedQueryDUnit.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public static String createRegionForTest(Boolean accessor) {
  Instantiator.register(new Instantiator(SerializableCompactLong.class, 79) {
    @Override
    public DataSerializable newInstance() {
      return new SerializableCompactLong();
    }
  });

  AttributesFactory attr = new AttributesFactory();
  attr.setDataPolicy(DataPolicy.PARTITION);
  PartitionAttributesFactory paf = new PartitionAttributesFactory();
  paf.setRedundantCopies(1);
  if (accessor.booleanValue()) {
    paf.setLocalMaxMemory(0);
  }
  PartitionAttributes prAttr = paf.create();
  attr.setPartitionAttributes(prAttr);
  Region reg = cache.createRegion("TESTLONG", attr.create());
  return reg.getFullPath();
}
 
Example 2
Source File: HDFSIntegrationUtil.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static String getLeaderRegionPath(String regionPath,
    RegionAttributes regionAttributes, Cache cache) {
  String colocated;
  while(regionAttributes.getPartitionAttributes() != null 
      && (colocated = regionAttributes.getPartitionAttributes().getColocatedWith()) != null) {
    // Do not waitOnInitialization() for PR
    GemFireCacheImpl gfc = (GemFireCacheImpl)cache;
    Region colocatedRegion = gfc.getPartitionedRegion(colocated, false);
    if(colocatedRegion == null) {
      Assert.fail("Could not find parent region " + colocated + " for " + regionPath);
    }
    regionAttributes = colocatedRegion.getAttributes();
    regionPath = colocatedRegion.getFullPath();
  }
  return regionPath;
}
 
Example 3
Source File: IndexManager.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public IndexManager(Region region) {
  this.region = region;
  this.logger = region.getCache().getLoggerI18n();
  // must be a SortedMap to ensure the indexes are iterated over in fixed
  // order
  // to avoid deadlocks when acquiring locks
  //indexes = Collections.synchronizedSortedMap(new TreeMap());
  indexMaintenanceSynchronous = region.getAttributes()
      .getIndexMaintenanceSynchronous();
  isOverFlowToDisk = region.getAttributes().getEvictionAttributes()
      .getAction().isOverflowToDisk();
  if (!indexMaintenanceSynchronous) {
    final LogWriterImpl.LoggingThreadGroup group =
      LogWriterImpl.createThreadGroup("QueryMonitor Thread Group", region.getCache().getLoggerI18n());
    updater = new IndexUpdaterThread(group, this.INDEX_MAINTENANCE_BUFFER,
                                     "OqlIndexUpdater:" + region.getFullPath());
    updater.start();
  }
}
 
Example 4
Source File: GetAll70.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static void sendGetAllResponseChunk(Region region, ObjectPartList list,
                                            boolean lastChunk, ServerConnection servConn) throws IOException {
  LogWriterI18n logger = servConn.getLogger();
  ChunkedMessage chunkedResponseMsg = servConn.getChunkedResponseMessage();
  chunkedResponseMsg.setNumberOfParts(1);
  chunkedResponseMsg.setLastChunk(lastChunk);
  chunkedResponseMsg.addObjPart(list, zipValues);

  if (logger.fineEnabled()) {
    String str = servConn.getName() + ": Sending" +
            (lastChunk ? " last " : " ") + "getAll response chunk for region=" +
            region.getFullPath() + (logger.finerEnabled()? " values=" + list + " chunk=<" +
            chunkedResponseMsg + ">" : "");
    logger.fine(str);
  }

  chunkedResponseMsg.sendChunk(servConn);
}
 
Example 5
Source File: GetAll.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static void sendGetAllResponseChunk(Region region, ObjectPartList list,
    boolean lastChunk, ServerConnection servConn) throws IOException {
  LogWriterI18n logger = servConn.getLogger();
  ChunkedMessage chunkedResponseMsg = servConn.getChunkedResponseMessage();
  chunkedResponseMsg.setNumberOfParts(1);
  chunkedResponseMsg.setLastChunk(lastChunk);
  chunkedResponseMsg.addObjPart(list, zipValues);

  if (logger.fineEnabled()) {
    String str = servConn.getName() + ": Sending"
        + (lastChunk ? " last " : " ") + "getAll response chunk for region="
        + region.getFullPath() + " values=" + list + " chunk=<"
        + chunkedResponseMsg + ">";
    logger.fine(str);
  }

  chunkedResponseMsg.sendChunk(servConn);
}
 
Example 6
Source File: PRListener.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void afterRegionCreate(Region<?, ?> aRegion) {
  Log.getLogWriter().info("In PRListener.afterRegionCreate for " + aRegion.getFullPath());
  synchronized (PRListener.class) {
    if (colocatedWithRegion != null) {
      throw new TestException("PRListener was installed in more than one region; it was already installed in " + 
                               colocatedWithRegion.getFullPath() + " and now is being installed in " + aRegion.getFullPath());
    }
    colocatedWithRegion = aRegion;
  }
}
 
Example 7
Source File: HDFSRegionBridge.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public HDFSRegionBridge(Region<K, V> region) {
  super(region);

  HDFSRegionDirector director = HDFSRegionDirector.getInstance();

  String regionFullPath = region.getFullPath();
  this.soplogStats = director.getHdfsRegionStats(regionFullPath);
  this.hdfsRegionMonitor = new MBeanStatsMonitor(HDFS_REGION_MONITOR + "_" + regionFullPath);
  hdfsRegionMonitor.addStatisticsToMonitor(soplogStats.getStats());
  this.parRegion = (PartitionedRegion)region;
  configureHDFSRegionMetrics();
}
 
Example 8
Source File: RegionOperations.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
public String createSubRegion(String name){
  synchronized (availableRegions) {      
      Region parent = RegionHelper.getRegion(name);
      String subregionName = "child" + OperationsBlackboard.getBB().getNextRegionCounter();
      logInfo("RegionOperations: Creating subregion named : " + subregionName + " with parent " + parent.getFullPath());
      RegionAttributes attr= parent.getAttributes();
      Region child = parent.createSubregion(subregionName, attr);
      logInfo("RegionOperations: Created subregion named " + child.getFullPath());
      availableRegions.add(child);
      operationRecorder.regionAdded(child);
      return child.getFullPath();      
  }   
}
 
Example 9
Source File: JMXTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private void validateWANEvents() {
  //temporary validation just to see if events are replicated or not
  Set<Region> regions = getRegionOperations().getAvailableRegions();
  Map<String,String> map = new HashMap();
  for(Region r : regions){
    String key = RemoteTestModule.getMyClientName() + r.getFullPath();
    String value = "VALUE";
    r.put(key, value);
    map.put(key, value);
  }    
  JMXBlackboard.getBB().saveMap("WANEVENTS_"+ RemoteTestModule.getMyClientName(), map);    
}
 
Example 10
Source File: ParRegUtil.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/** Verify that the size of the given region is expectedSize.
 *
 * @param aRegion The region to verify.
 * @param expectedSize The expected size of aRegion.
 *
 * @throws TestException if size() has the wrong value
 */
public static void verifySize(Region aRegion, final int expectedSize) {
  int size = aRegion.size();
  if (size != expectedSize) {
    ParRegUtilVersionHelper.dumpBackingMap(aRegion);
    throw new TestException("Expected size of " + aRegion.getFullPath() + " to be " +
       expectedSize + ", but it is " + size);
  }
}
 
Example 11
Source File: PRObserver.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/** Callback for moving a bucket
 */
public synchronized void movingBucket(Region region, 
                         int bucketId,
                         DistributedMember source, 
                         DistributedMember target) {
   if (recordBucketMoves) {
      String aStr = "moving bucket with ID " + bucketId + " in " + 
          region.getFullPath() + " from " + source + " to " + target;
      Log.getLogWriter().info("PRObserver: " + aStr);
      _addToActivityList(movingBucket + new Date() + "; " + aStr);
   }
}
 
Example 12
Source File: JMXTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private void validateWANEvents() {
  //temporary validation just to see if events are replicated or not
  Set<Region> regions = getRegionOperations().getAvailableRegions();
  Map<String,String> map = new HashMap();
  for(Region r : regions){
    String key = RemoteTestModule.getMyClientName() + r.getFullPath();
    String value = "VALUE";
    r.put(key, value);
    map.put(key, value);
  }    
  JMXBlackboard.getBB().saveMap("WANEVENTS_"+ RemoteTestModule.getMyClientName(), map);    
}
 
Example 13
Source File: HDFSRegionBridge.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public HDFSRegionBridge(Region<K, V> region) {
  super(region);

  HDFSRegionDirector director = HDFSRegionDirector.getInstance();

  String regionFullPath = region.getFullPath();
  this.soplogStats = director.getHdfsRegionStats(regionFullPath);
  this.hdfsRegionMonitor = new MBeanStatsMonitor(HDFS_REGION_MONITOR + "_" + regionFullPath);
  hdfsRegionMonitor.addStatisticsToMonitor(soplogStats.getStats());
  this.parRegion = (PartitionedRegion)region;
  configureHDFSRegionMetrics();
}
 
Example 14
Source File: WANOperationsClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public synchronized void updateBlackboardSnapshot(Region aRegion, Object key,
    Object value, boolean isRemove) {
  OperationCountersBB.getBB().getSharedLock().lock();
  Map smap = getBBSnapshotForUniqueKeyMap(aRegion);
  if (isRemove) {
    smap.remove(key);
  }
  else {
    smap.put(key, value);
  }
  String snapshotKey = SNAPSHOT_FOR_UNIQUE_KEY_PREFIX + aRegion.getFullPath();
  OperationCountersBB.getBB().getSharedMap().put(snapshotKey, smap);
  OperationCountersBB.getBB().getSharedLock().unlock();
}
 
Example 15
Source File: ManagementAdapter.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Handles particular region destroy or close operation it will remove the
 * corresponding MBean
 * 
 * @param region
 */
public void handleRegionRemoval(Region region) throws ManagementException{
  if (!isServiceInitialised("handleRegionRemoval")) {
    return;
  }
  /**
   * Moved region remove operation to a guarded block. If a region is getting
   * created it wont allow it to destroy any region.
   */

  synchronized(regionOpLock){

    ObjectName regionMBeanName = MBeanJMXAdapter.getRegionMBeanName(cacheImpl
        .getDistributedSystem().getDistributedMember(), region.getFullPath());
    RegionMBean bean = null;
    try {
      bean = (RegionMBean)service.getLocalRegionMBean(region.getFullPath());
    } catch (ManagementException e) {
      LogWriterI18n logger = InternalDistributedSystem.getLoggerI18n();
      // If no bean found its a NO-OP
      // Mostly for situation like DiskAccessException while creating region
      // which does a compensatory close region
      if (logger != null && logger.fineEnabled()) {
        logger.fine(e);
      }
      return;
    }
    
    if(bean != null){
      bean.stopMonitor();
    }
    service.unregisterMBean(regionMBeanName);

    Notification notification = new Notification(
        ResourceNotification.REGION_CLOSED, memberSource, SequenceNumber.next(),
        System.currentTimeMillis(), ResourceNotification.REGION_CLOSED_PREFIX
            + region.getFullPath());
    memberLevelNotifEmitter.sendNotification(notification);
    memberMBeanBridge.removeRegion(region);
  }

}
 
Example 16
Source File: DynamicRegionTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Puts object into a dynamically created region.   Each logical hydra client puts a configurable
 * number of entries each with a unique key.
 */
protected void putData() {

   int numEntries = TestConfig.tab().intAt(DynamicRegionPrms.maxEntries);

   // select random region, may be root
   Region aRegion = getRandomRegion(true);
   String drName = aRegion.getName() + "_DYNAMIC";
   Log.getLogWriter().info("### creating dynamic region using parent: " + aRegion.getFullPath());
   Log.getLogWriter().info("### dynamic region name will be: " + drName);

   Log.getLogWriter().info("### randomly selected region name: " + aRegion.getName());
   Log.getLogWriter().info("### randomly selected region path: " + aRegion.getFullPath());

   createDynamicRegion(aRegion.getFullPath(), drName);

   Cache myCache = CacheHelper.getCache();
   String drPath = aRegion.getFullPath() + "/" + drName;   
   Region dynRegion = myCache.getRegion(drPath);
   Log.getLogWriter().info("### creating dynamic region");
   Log.getLogWriter().info("Region is: " + dynRegion.getFullPath());

   OpList opList = new OpList();
  
   for (int i=0; i < numEntries; i++) {
     String name = NameFactory.getNextPositiveObjectName();
     Object anObj = new ValueHolder(name, new RandomValues());

     try {
         dynRegion.put(name, anObj);
         Operation op  = new Operation (dynRegion.getFullPath(), name, Operation.ENTRY_CREATE, null, anObj); 
         opList.add(op);
     } catch (Exception e) {
         throw new TestException(TestHelper.getStackTrace(e));
     }

   }

   DynamicRegionBB.putSingleOpList(opList);

}
 
Example 17
Source File: EntryOperations.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
private static void doExecuteCQ(Region region, String userName, Map[] maps,
    Boolean isDurable) {
  Map opMap = maps[0];
  Map exMap = maps[1];
  String key = getKeyForOperation();
  boolean doAddOperation = true;

  String operation = "EXECUTE_CQ";
  String cqName1 = "CQ1_" + userName;
  String cqName2 = "CQ2_" + userName;
  SelectResults cqResults = null;
  String queryString = "SELECT * FROM " + region.getFullPath();
  //QueryService qs = region.getCache().getQueryService();
  QueryService qs = PerUserRequestSecurityTest.proxyAuthenticatedCacheMap.get(userName).getQueryService();

  try {
    CqAttributesFactory cqf = new CqAttributesFactory();
    CqListener[] cqListeners1 = { new CqQueryTestListener(Log.getLogWriter()) };
    ((CqQueryTestListener)cqListeners1[0]).cqName = cqName1;
    ((CqQueryTestListener)cqListeners1[0]).userName = userName;
    cqf.initCqListeners(cqListeners1);
    CqAttributes cqAttributes = cqf.create();
    CqQuery cq1 = qs.newCq(cqName1, queryString, cqAttributes, isDurable);
    cq1.execute();

    CqListener[] cqListeners2 = { new CqQueryTestListener(Log.getLogWriter()) };
    ((CqQueryTestListener)cqListeners2[0]).cqName = cqName2;
    ((CqQueryTestListener)cqListeners2[0]).userName = userName;
    cqf.initCqListeners(cqListeners2);
    cqAttributes = cqf.create();
    CqQuery cq2 = qs.newCq(cqName2, queryString, cqAttributes, isDurable);
    cqResults = cq2.executeWithInitialResults();
  }

  catch (Exception ex) {
    if (ex instanceof CacheLoaderException
        || ex instanceof CacheWriterException
        || (ex instanceof ServerConnectivityException && ex.getCause() instanceof NotAuthorizedException)
        || (ex instanceof CqException && ex.getCause() instanceof NotAuthorizedException)
        || (ex instanceof ServerOperationException && ex.getCause() instanceof NotAuthorizedException)) {

      Log.getLogWriter().info(
          "Got expected NotAuthorizedException when doing " + operation
              + " operation for " + userName + " : " + ex.getCause());
      synchronized (exMap) {
        Integer tmpNotAuthzCount = (Integer)exMap.get(operation);

        if (tmpNotAuthzCount == null) {
          exMap.put(operation, new Integer(1));
        }
        else {
          exMap.put(operation, new Integer(tmpNotAuthzCount.intValue() + 1));
        }
      }
    }
    else {
      doAddOperation = false;
      throw new TestException("Exception while CQ Operation for user :"
          + userName + " ", ex);

    }
  }
  finally {
    synchronized (opMap) {
      if (doAddOperation) {
        Integer tmpTotalOperation = (Integer)opMap.get(operation);

        if (tmpTotalOperation == null) {
          opMap.put(operation, new Integer(1));
        }
        else {
          opMap.put(operation, new Integer(tmpTotalOperation.intValue() + 1));
        }
      }
      Log.getLogWriter().fine(
          "For user :: " + userName + " operation : " + operation
              + " operation count is " + (Integer)opMap.get(operation)
              + " And Exception count is :: " + (Integer)exMap.get(operation)
              + " key is " + key);
    }
  }
}
 
Example 18
Source File: WANTestBase.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static String getRegionFullPath(String regionName) {
  final Region r = cache.getRegion(Region.SEPARATOR + regionName);
  assertNotNull(r);
  return r.getFullPath();
}
 
Example 19
Source File: WANTestBase.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static String getRegionFullPath(String regionName) {
  final Region r = cache.getRegion(Region.SEPARATOR + regionName);
  assertNotNull(r);
  return r.getFullPath();
}
 
Example 20
Source File: RegionTestMBean.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void destroyRegion(JMXOperations ops, ObjectName targetMbean)throws IOException{
  logInfo(prefix + " Calling destroyRegion");
  RegionOperations regionOps = JMXTest.getRegionOperations();
  List<String> regions = RegionEvents.getAllRegions(RemoteTestModule.getMyClientName());
  List deletedRegions = JMXBlackboard.getBB().getList(JMXBlackboard.REGION_DELETE_LIST);
  //Set<Region> regions = regionOps.getAvailableRegions();
  logInfo(prefix + " Regions Created in this VM : " + regions);
  logInfo(prefix + " Regions Deleted in all VMs : " + deletedRegions);
  
  Region regionToDelete = null;
  for(int i=0;i<regions.size();i++){
    regionToDelete = RegionHelper.getRegion(regions.get(i));
    if(regionToDelete!=null && !deletedRegions.equals(regionToDelete))
      break;
  }
  if(regionToDelete!=null){
    String name = regionToDelete.getName();
    String regionPath = regionToDelete.getFullPath();
    regionOps.destroyRegion(regionToDelete);
    JMXBlackboard.getBB().addToList(JMXBlackboard.REGION_DELETE_LIST, regionPath);
    logInfo(prefix + " Finished with destroying region named " + name + " adding a notif expectation");
    addRegionDestroyNotificationExp(regionPath);
    logInfo(prefix + " Waiting for sleepReplication");
    HydraUtil.sleepForReplicationJMX();      
    DistributedMember distributedMember = InternalDistributedSystem.getConnectedInstance().getDistributedMember();
    ObjectName regionName = JMXTest.getManagementService().getRegionMBeanName(distributedMember, regionPath);
    ObjectName distributedRegionName = MBeanJMXAdapter.getDistributedRegionMbeanName(regionPath);
    String url = ops.selectManagingNode();
    MBeanServerConnection server = ManagementUtil.connectToUrlOrGemfireProxy(url);
    logInfo(prefix + " Checking for " + regionPath + " MBeans at node " + url);
    targetMbean = regionName;
    if (ManagementUtil.checkIfMBeanExists(server, targetMbean))
      throw new TestException("Proxy to " + targetMbean + " is stil present at " + url);
    
    targetMbean = distributedRegionName;
    if (ManagementUtil.checkIfMBeanExists(server, targetMbean))
      throw new TestException("Proxy to " + targetMbean + " is stil present at " + url);
    
  }else{
    throw new TestException("No Regions found in this VM for destoroRegion Test case");
  }
  logInfo(prefix + " Completed destroyRegion test successfully");
}