Exemplo n.º 1
0
  boolean isUsedInPartitioning() {
    boolean ok = false;
    // TODO: Asif: Handle this case where region is turning out to be null
    // Ideally Bug 39923 workaround should ensure that region is not null. But we are doing
    // this check only for Update type statements. For Select queries, it may stll be null,
    // hence the check

    if (this.tqi == null) {
      return ok;
    }
    Region rgnOwningColumn = this.tqi.getRegion();
    assert rgnOwningColumn != null;
    RegionAttributes ra = rgnOwningColumn.getAttributes();
    // If the region is a Replicated Region or if it is a PR with just
    // itself
    // as a member then we should go with Derby's Activation Object
    DataPolicy policy = ra.getDataPolicy();

    if (policy.withPartitioning()) {
      PartitionedRegion pr = (PartitionedRegion) rgnOwningColumn;
      GfxdPartitionResolver rslvr = (GfxdPartitionResolver) pr.getPartitionResolver();
      ok = rslvr != null && rslvr.isUsedInPartitioning(this.actualColumnName);
    }
    return ok;
  }
    protected DataPolicy resolveDataPolicy(final String dataPolicyName) {
      try {
        for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) {
          DataPolicy dataPolicy = DataPolicy.fromOrdinal(ordinal);

          if (dataPolicy.toString().equalsIgnoreCase(dataPolicyName)) {
            return dataPolicy;
          }
        }
      } catch (Exception ignore) {
      }

      return null;
    }
 /**
  * Validates that the settings for Data Policy and the 'persistent' attribute in
  * &lt;gfe:*-region&gt; elements are compatible.
  *
  * @param resolvedDataPolicy the GemFire Data Policy resolved form the Spring GemFire XML
  *     namespace configuration meta-data.
  * @see #isPersistent()
  * @see #isNotPersistent()
  * @see com.gemstone.gemfire.cache.DataPolicy
  */
 protected void assertDataPolicyAndPersistentAttributesAreCompatible(
     DataPolicy resolvedDataPolicy) {
   if (resolvedDataPolicy.withPersistence()) {
     Assert.isTrue(
         isPersistentUnspecified() || isPersistent(),
         String.format(
             "Data Policy '%1$s' is invalid when persistent is false.", resolvedDataPolicy));
   } else {
     // NOTE otherwise, the Data Policy is not persistent, so...
     Assert.isTrue(
         isPersistentUnspecified() || isNotPersistent(),
         String.format(
             "Data Policy '%1$s' is invalid when persistent is true.", resolvedDataPolicy));
   }
 }
  /** * Returns Map of the non default Attributes and its values */
  public Map<String, String> getNonDefaultAttributes() {

    if (nonDefaultAttributes == null) {
      nonDefaultAttributes = new HashMap<String, String>();

      if (cloningEnabled != RegionAttributesDefault.CLONING_ENABLED) {
        nonDefaultAttributes.put(
            RegionAttributesNames.CLONING_ENABLED, Boolean.toString(cloningEnabled));
      }

      if (compressorClassName != RegionAttributesDefault.COMPRESSOR_CLASS_NAME) {
        nonDefaultAttributes.put(RegionAttributesNames.COMPRESSOR, compressorClassName);
      }

      if (concurrencyChecksEnabled != RegionAttributesDefault.CONCURRENCY_CHECK_ENABLED) {
        nonDefaultAttributes.put(
            RegionAttributesNames.CONCURRENCY_CHECK_ENABLED,
            Boolean.toString(concurrencyChecksEnabled));
      }

      if (concurrencyLevel != RegionAttributesDefault.CONCURRENCY_LEVEL) {
        nonDefaultAttributes.put(
            RegionAttributesNames.CONCURRENCY_LEVEL, Integer.toString(concurrencyLevel));
      }

      if (dataPolicy.equals(RegionAttributesDefault.DATA_POLICY)) {
        nonDefaultAttributes.put(RegionAttributesNames.DATA_POLICY, dataPolicy.toString());
      }

      if (diskStoreName != null && diskStoreName.equals(RegionAttributesDefault.DISK_STORE_NAME)) {
        nonDefaultAttributes.put(RegionAttributesNames.DISK_STORE_NAME, diskStoreName);
      }

      if (enableAsyncConflation != RegionAttributesDefault.ENABLE_ASYNC_CONFLATION) {
        nonDefaultAttributes.put(
            RegionAttributesNames.ENABLE_ASYNC_CONFLATION, Boolean.toString(enableAsyncConflation));
      }

      if (enableGateway != RegionAttributesDefault.ENABLE_GATEWAY) {
        nonDefaultAttributes.put(
            RegionAttributesNames.ENABLE_GATEWAY, Boolean.toString(enableGateway));
      }

      if (enableSubscriptionConflation != RegionAttributesDefault.ENABLE_SUBSCRIPTION_CONFLATION) {
        nonDefaultAttributes.put(
            RegionAttributesNames.ENABLE_SUBSCRIPTION_CONFLATION,
            Boolean.toString(enableSubscriptionConflation));
      }

      if (entryIdleTimeout != RegionAttributesDefault.ENTRY_IDLE_TIMEOUT) {
        nonDefaultAttributes.put(
            RegionAttributesNames.ENTRY_IDLE_TIMEOUT, Integer.toString(entryIdleTimeout));
      }

      if (gatewayHubId != null
          && !gatewayHubId.isEmpty()
          && !gatewayHubId.equals(RegionAttributesDefault.GATEWAY_HUB_ID)) {
        nonDefaultAttributes.put(RegionAttributesNames.GATEWAY_HUB_ID, gatewayHubId);
      }

      if (ignoreJTA != RegionAttributesDefault.IGNORE_JTA) {
        nonDefaultAttributes.put(RegionAttributesNames.IGNORE_JTA, Boolean.toString(ignoreJTA));
      }

      if (indexMaintenanceSynchronous != RegionAttributesDefault.INDEX_MAINTENANCE_SYNCHRONOUS) {
        nonDefaultAttributes.put(
            RegionAttributesNames.INDEX_MAINTENANCE_SYNCHRONOUS,
            Boolean.toString(indexMaintenanceSynchronous));
      }

      if (initialCapacity != RegionAttributesDefault.INITIAL_CAPACITY) {
        nonDefaultAttributes.put(
            RegionAttributesNames.INITIAL_CAPACITY, Integer.toString(initialCapacity));
      }

      if (loadFactor != RegionAttributesDefault.LOAD_FACTOR) {
        nonDefaultAttributes.put(RegionAttributesNames.LOAD_FACTOR, Float.toString(loadFactor));
      }

      if (multicastEnabled != RegionAttributesDefault.MULTICAST_ENABLED) {
        nonDefaultAttributes.put(
            RegionAttributesNames.MULTICAST_ENABLED, Boolean.toString(multicastEnabled));
      }

      if (poolName != null && !poolName.equals(RegionAttributesDefault.POOL_NAME)) {
        nonDefaultAttributes.put(RegionAttributesNames.POOL_NAME, poolName);
      }

      if (scope.equals(RegionAttributesDefault.SCOPE)) {
        nonDefaultAttributes.put(RegionAttributesNames.SCOPE, scope.toString());
      }

      if (statisticsEnabled != RegionAttributesDefault.STATISTICS_ENABLED) {
        nonDefaultAttributes.put(
            RegionAttributesNames.STATISTICS_ENABLED, Boolean.toString(statisticsEnabled));
      }

      if (isLockGrantor != RegionAttributesDefault.IS_LOCK_GRANTOR) {
        nonDefaultAttributes.put(
            RegionAttributesNames.IS_LOCK_GRANTOR, Boolean.toString(isLockGrantor));
      }

      if (entryIdleTimeout != RegionAttributesDefault.ENTRY_IDLE_TIMEOUT) {
        nonDefaultAttributes.put(
            RegionAttributesNames.ENTRY_IDLE_TIMEOUT, Integer.toString(entryIdleTimeout));
      }

      if (entryIdleTimeoutAction != null
          && !entryIdleTimeoutAction.equals(RegionAttributesDefault.ENTRY_IDLE_TIMEOUT_ACTION)) {
        nonDefaultAttributes.put(
            RegionAttributesNames.ENTRY_IDLE_TIMEOUT_ACTION, entryIdleTimeoutAction);
      }

      if (entryTimeToLive != RegionAttributesDefault.ENTRY_TIME_TO_LIVE) {
        nonDefaultAttributes.put(
            RegionAttributesNames.ENTRY_TIME_TO_LIVE, Integer.toString(entryTimeToLive));
      }

      if (entryTimeToLiveAction != null
          && !entryTimeToLiveAction.equals(RegionAttributesDefault.ENTRY_TIME_TO_LIVE_ACTION)) {
        nonDefaultAttributes.put(
            RegionAttributesNames.ENTRY_TIME_TO_LIVE_ACTION, entryTimeToLiveAction);
      }

      if (regionIdleTimeout != RegionAttributesDefault.REGION_IDLE_TIMEOUT) {
        nonDefaultAttributes.put(
            RegionAttributesNames.REGION_IDLE_TIMEOUT, Integer.toString(regionIdleTimeout));
      }

      if (regionIdleTimeoutAction != null
          && !regionIdleTimeoutAction.equals(RegionAttributesDefault.REGION_IDLE_TIMEOUT_ACTION)) {
        nonDefaultAttributes.put(
            RegionAttributesNames.REGION_IDLE_TIMEOUT_ACTION, regionIdleTimeoutAction);
      }

      if (regionTimeToLive != RegionAttributesDefault.REGION_TIME_TO_LIVE) {
        nonDefaultAttributes.put(
            RegionAttributesNames.REGION_TIME_TO_LIVE, Integer.toString(regionTimeToLive));
      }

      if (regionTimeToLiveAction != null
          && !regionTimeToLiveAction.equals(RegionAttributesDefault.REGION_TIME_TO_LIVE_ACTION)) {
        nonDefaultAttributes.put(
            RegionAttributesNames.REGION_TIME_TO_LIVE_ACTION, regionTimeToLiveAction);
      }

      if (cacheListenerClassNames != null && !cacheListenerClassNames.isEmpty()) {
        nonDefaultAttributes.put(
            RegionAttributesNames.CACHE_LISTENERS,
            CliUtil.convertStringListToString(cacheListenerClassNames, ','));
      }

      if (cacheLoaderClassName != null && !cacheLoaderClassName.isEmpty()) {
        nonDefaultAttributes.put(RegionAttributesNames.CACHE_LOADER, cacheLoaderClassName);
      }

      if (cacheWriterClassName != null && !cacheWriterClassName.isEmpty()) {
        nonDefaultAttributes.put(RegionAttributesNames.CACHE_WRITER, cacheWriterClassName);
      }
    }
    return this.nonDefaultAttributes;
  }