Ejemplo n.º 1
0
 @Override
 public HPCMemoryConfig apply(HPCMemoryConfig input, Function<String, String> settings) {
   if (input.total() > (heap() * 0.8)) {
     throw new InvalidSettingException(
         HighPerformanceCacheSettings.cache_memory.name(),
         String.format(
             "Configured object cache memory limits (node=%s, relationship=%s, "
                 + "total=%s) exceeds 80%% of available heap space (%s)",
             input.nodeCacheSize(), input.relCacheSize(), input.total(), heap()));
   }
   return input;
 }
Ejemplo n.º 2
0
            @Override
            public HPCMemoryConfig apply(
                HPCMemoryConfig basedOnRatio, Function<String, String> settings) {
              String explicitNodeCacheSize =
                  settings.apply(HighPerformanceCacheSettings.node_cache_size.name());
              String explicitRelCacheSize =
                  settings.apply(HighPerformanceCacheSettings.relationship_cache_size.name());
              String explicitNodeArrayFraction =
                  settings.apply(HighPerformanceCacheSettings.node_cache_array_fraction.name());
              String explicitRelArrayFraction =
                  settings.apply(
                      HighPerformanceCacheSettings.relationship_cache_array_fraction.name());

              if (explicitNodeCacheSize != null
                  || explicitRelCacheSize != null
                  || explicitNodeArrayFraction != null
                  || explicitRelArrayFraction != null) {
                // At least one explicit config set, swap to explicit mode
                long nodeCacheBytes =
                    explicitNodeCacheSize != null ? BYTES.apply(explicitNodeCacheSize) : heap() / 8;
                long relCacheBytes =
                    explicitRelCacheSize != null ? BYTES.apply(explicitRelCacheSize) : heap() / 8;
                float nodeArrRatio =
                    explicitNodeArrayFraction != null
                        ? FLOAT.apply(explicitNodeArrayFraction)
                        : 1.0f;
                float relArrRatio =
                    explicitRelArrayFraction != null ? FLOAT.apply(explicitRelArrayFraction) : 1.0f;

                // Figure out if user is inadvertently overwriting her own configuration
                HPCMemoryConfig.Source source =
                    basedOnRatio.source() == HPCMemoryConfig.Source.DEFAULT_MEMORY_RATIO
                        ? HPCMemoryConfig.Source.SPECIFIC
                        : HPCMemoryConfig.Source.SPECIFIC_OVERRIDING_RATIO;
                return new HPCMemoryConfig(
                    nodeCacheBytes, relCacheBytes, nodeArrRatio, relArrRatio, source);
              }

              return basedOnRatio;
            }