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

The following examples show how to use com.gemstone.gemfire.cache.Region#getUserAttribute() . 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: CallbackProcedures.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Get the {@link GemFireContainer} for given schema.table. The arguments can
 * be case-sensitive or case-insensitive since this method will try for both.
 * If the schema is null, then the current schema is tried.
 */
public static GemFireContainer getContainerForTable(String schemaName,
    String tableName) throws StandardException {
  GemFireContainer container;
  if (schemaName == null || schemaName.length() == 0) {
    schemaName = Misc.getDefaultSchemaName(null);
  }
  Region<Object, Object> reg = Misc.getRegionByPath(
      Misc.getRegionPath(schemaName, tableName, null), false);
  if (reg == null
      || (container = (GemFireContainer)reg.getUserAttribute()) == null) {
    // assume case-insensitive
    if (schemaName != null && schemaName.length() > 0) {
      schemaName = StringUtil.SQLToUpperCase(schemaName);
    }
    tableName = StringUtil.SQLToUpperCase(tableName);
    reg = Misc.getRegionByPath(
        Misc.getRegionPath(schemaName, tableName, null), false);
    if (reg == null
        || (container = (GemFireContainer)reg.getUserAttribute()) == null) {
      throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND,
          Misc.getFullTableName(schemaName, tableName, null));
    }
  }
  return container;
}
 
Example 2
Source File: GemFireUpdateResultSet.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Take lock on target table being inserted into for inserts as sub-selects.
 */
private void takeLockOnTargetTable() throws StandardException {
  if (this.targetTableName != null) {
    if (this.targetTableContainer == null) {
      final Region<?, ?> targetRegion = Misc
          .getRegionForTable(this.targetTableName, false);
      if (targetRegion == null) {
        throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND,
            this.targetTableName);
      }
      this.targetTableContainer = (GemFireContainer)targetRegion
          .getUserAttribute();
    }
    if (this.targetTableContainer != null) {
      this.targetTableContainer
          .open(this.tran, ContainerHandle.MODE_READONLY);
    }
  }
}
 
Example 3
Source File: CallbackProcedures.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Get the {@link GemFireContainer} for given schema.table. The arguments can
 * be case-sensitive or case-insensitive since this method will try for both.
 * If the schema is null, then the current schema is tried.
 */
public static GemFireContainer getContainerForTable(String schemaName,
    String tableName) throws StandardException {
  GemFireContainer container;
  if (schemaName == null || schemaName.length() == 0) {
    schemaName = Misc.getDefaultSchemaName(null);
  }
  Region<Object, Object> reg = Misc.getRegionByPath(
      Misc.getRegionPath(schemaName, tableName, null), false);
  if (reg == null
      || (container = (GemFireContainer)reg.getUserAttribute()) == null) {
    // assume case-insensitive
    if (schemaName != null && schemaName.length() > 0) {
      schemaName = StringUtil.SQLToUpperCase(schemaName);
    }
    tableName = StringUtil.SQLToUpperCase(tableName);
    reg = Misc.getRegionByPath(
        Misc.getRegionPath(schemaName, tableName, null), false);
    if (reg == null
        || (container = (GemFireContainer)reg.getUserAttribute()) == null) {
      throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND,
          Misc.getFullTableName(schemaName, tableName, null));
    }
  }
  return container;
}
 
Example 4
Source File: GemFireUpdateResultSet.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Take lock on target table being inserted into for inserts as sub-selects.
 */
private void takeLockOnTargetTable() throws StandardException {
  if (this.targetTableName != null) {
    if (this.targetTableContainer == null) {
      final Region<?, ?> targetRegion = Misc
          .getRegionForTable(this.targetTableName, false);
      if (targetRegion == null) {
        throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND,
            this.targetTableName);
      }
      this.targetTableContainer = (GemFireContainer)targetRegion
          .getUserAttribute();
    }
    if (this.targetTableContainer != null) {
      this.targetTableContainer
          .open(this.tran, ContainerHandle.MODE_READONLY);
    }
  }
}
 
Example 5
Source File: GemFireXDUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Get the {@link GemFireContainer} for given table in provided schema.
 */
public static GemFireContainer getGemFireContainer(String schemaName,
    String tableName, LanguageConnectionContext lcc) {
  if (tableName != null) {
    final Region<?, ?> region = Misc.getRegionByPath(
        Misc.getRegionPath(schemaName, tableName, lcc), false);
    if (region != null) {
      return (GemFireContainer)region.getUserAttribute();
    }
  }
  return null;
}
 
Example 6
Source File: SqlOffHeapHelper.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/** Return whether the given Region is a global index table.
 * 
 * @param aRegion The region to test.
 * @return true if aRegion is a global index table, false otherwise.
 */
private static boolean isGlobalIndexTable(Region aRegion) {
  Object attr = aRegion.getUserAttribute();
  if (attr != null) {
    if (attr instanceof GemFireContainer) {
      GemFireContainer container = (GemFireContainer)attr;
      return container.isGlobalIndex();
    }
  }
  return false;
}
 
Example 7
Source File: GemFireXDUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Get the {@link GemFireContainer} for given table in provided schema.
 */
public static GemFireContainer getGemFireContainer(String schemaName,
    String tableName, LanguageConnectionContext lcc) {
  if (tableName != null) {
    final Region<?, ?> region = Misc.getRegionByPath(
        Misc.getRegionPath(schemaName, tableName, lcc), false);
    if (region != null) {
      return (GemFireContainer)region.getUserAttribute();
    }
  }
  return null;
}
 
Example 8
Source File: SqlOffHeapHelper.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/** Return whether the given Region is a global index table.
 * 
 * @param aRegion The region to test.
 * @return true if aRegion is a global index table, false otherwise.
 */
private static boolean isGlobalIndexTable(Region aRegion) {
  Object attr = aRegion.getUserAttribute();
  if (attr != null) {
    if (attr instanceof GemFireContainer) {
      GemFireContainer container = (GemFireContainer)attr;
      return container.isGlobalIndex();
    }
  }
  return false;
}