コード例 #1
0
  @Override
  public void updateCacheManager(String cacheManagerName, CacheManagerEntity resource)
      throws ServiceExecutionException {
    cacheManagerSamplerRepoLock.writeLock().lock();

    try {
      SamplerRepoEntry entry = cacheManagerSamplerRepo.get(cacheManagerName);
      if (entry != null) {
        CacheManagerSampler cms = entry.getCacheManagerSampler();
        checkForInvalidAttributes(cacheManagerName, resource);

        Object mbldsAttr =
            resource.getAttributes().get(SamplerRepoEntry.MAX_BYTES_LOCAL_DISK_STRING);
        if (mbldsAttr != null) cms.setMaxBytesLocalDiskAsString(mbldsAttr.toString());

        Object mblhsAttr =
            resource.getAttributes().get(SamplerRepoEntry.MAX_BYTES_LOCAL_HEAP_STRING);
        if (mblhsAttr != null) cms.setMaxBytesLocalHeapAsString(mblhsAttr.toString());
      } else {
        throw new ServiceExecutionException("CacheManager not found !");
      }
    } finally {
      cacheManagerSamplerRepoLock.writeLock().unlock();
    }
  }
コード例 #2
0
  @Override
  public Collection<QueryResultsEntity> executeQuery(String cacheManagerName, String queryString)
      throws ServiceExecutionException {
    cacheManagerSamplerRepoLock.writeLock().lock();

    try {
      SamplerRepoEntry entry = cacheManagerSamplerRepo.get(cacheManagerName);
      if (entry != null) {
        try {
          enableNonStopFor(entry, false);
          CacheManagerSampler cms = entry.getCacheManagerSampler();
          return buildQueryResultsEntity(cacheManagerName, cms.executeQuery(queryString));
        } catch (Exception e) {
          Throwable t = ExceptionUtils.getRootCause(e);
          throw new ServiceExecutionException(t.getMessage());
        } finally {
          enableNonStopFor(entry, true);
        }
      } else {
        throw new ServiceExecutionException("CacheManager not found !");
      }
    } finally {
      cacheManagerSamplerRepoLock.writeLock().unlock();
    }
  }
コード例 #3
0
  /** {@inheritDoc} */
  public void unregister(CacheManager cacheManager) {
    cacheManagerSamplerRepoLock.writeLock().lock();

    try {
      SamplerRepoEntry entry = cacheManagerSamplerRepo.remove(cacheManager.getName());
      entry.destroy();
    } finally {
      cacheManagerSamplerRepoLock.writeLock().unlock();
    }
  }
コード例 #4
0
  @Override
  public void clearCache(String cacheManagerName, String cacheName) {
    cacheManagerSamplerRepoLock.readLock().lock();

    SamplerRepoEntry entry = cacheManagerSamplerRepo.get(cacheManagerName);
    try {
      enableNonStopFor(entry, false);
      if (entry != null) entry.clearCache(cacheName);
    } finally {
      enableNonStopFor(entry, true);
      cacheManagerSamplerRepoLock.readLock().unlock();
    }
  }
コード例 #5
0
  @Override
  public void createOrUpdateCache(String cacheManagerName, String cacheName, CacheEntity resource)
      throws ServiceExecutionException {
    cacheManagerSamplerRepoLock.readLock().lock();

    try {
      SamplerRepoEntry entry = cacheManagerSamplerRepo.get(cacheManagerName);
      if (entry != null) entry.updateCache(cacheName, resource);
      else throw new ServiceExecutionException("CacheManager not found !");
    } finally {
      cacheManagerSamplerRepoLock.readLock().unlock();
    }
  }
コード例 #6
0
  @Override
  public Collection<CacheEntityV2> createCacheEntities(
      Set<String> cacheManagerNames, Set<String> cacheNames, Set<String> attributes) {
    CacheEntityBuilderV2 builder = null;
    Collection<CacheEntityV2> entities;

    cacheManagerSamplerRepoLock.readLock().lock();

    List<SamplerRepoEntry> disabledSamplerRepoEntries = new ArrayList<SamplerRepoEntry>();

    try {
      if (cacheManagerNames == null) {
        for (Map.Entry<String, SamplerRepoEntry> entry : cacheManagerSamplerRepo.entrySet()) {
          enableNonStopFor(entry.getValue(), false);
          disabledSamplerRepoEntries.add(entry.getValue());
          for (CacheSampler sampler : entry.getValue().getComprehensiveCacheSamplers(cacheNames)) {
            builder =
                builder == null
                    ? CacheEntityBuilderV2.createWith(sampler, entry.getKey())
                    : builder.add(sampler, entry.getKey());
          }
        }
      } else {
        for (String cmName : cacheManagerNames) {
          SamplerRepoEntry entry = cacheManagerSamplerRepo.get(cmName);
          if (entry != null) {
            enableNonStopFor(entry, false);
            disabledSamplerRepoEntries.add(entry);
            for (CacheSampler sampler : entry.getComprehensiveCacheSamplers(cacheNames)) {
              builder =
                  builder == null
                      ? CacheEntityBuilderV2.createWith(sampler, cmName)
                      : builder.add(sampler, cmName);
            }
          }
        }
      }
      if (builder == null) {
        entities = new HashSet<CacheEntityV2>(0);
      } else {
        entities = attributes == null ? builder.build() : builder.add(attributes).build();
      }
    } finally {
      for (SamplerRepoEntry samplerRepoEntry : disabledSamplerRepoEntries) {
        enableNonStopFor(samplerRepoEntry, true);
      }
      cacheManagerSamplerRepoLock.readLock().unlock();
    }

    return entities;
  }
コード例 #7
0
  @Override
  public Collection<CacheConfigEntityV2> createCacheConfigEntities(
      Set<String> cacheManagerNames, Set<String> cacheNames) {
    CacheConfigurationEntityBuilderV2 builder = null;
    Collection<CacheConfigEntityV2> entities;

    cacheManagerSamplerRepoLock.readLock().lock();

    try {
      if (cacheManagerNames == null) {
        for (Map.Entry<String, SamplerRepoEntry> entry : cacheManagerSamplerRepo.entrySet()) {
          for (CacheSampler sampler : entry.getValue().getComprehensiveCacheSamplers(cacheNames)) {
            builder =
                builder == null
                    ? CacheConfigurationEntityBuilderV2.createWith(
                        entry.getValue().getCacheManagerSampler(), sampler.getCacheName())
                    : builder.add(
                        entry.getValue().getCacheManagerSampler(), sampler.getCacheName());
          }
        }
      } else {
        for (String cmName : cacheManagerNames) {
          SamplerRepoEntry entry = cacheManagerSamplerRepo.get(cmName);
          if (entry != null) {
            for (CacheSampler sampler : entry.getComprehensiveCacheSamplers(cacheNames)) {
              builder =
                  builder == null
                      ? CacheConfigurationEntityBuilderV2.createWith(
                          entry.getCacheManagerSampler(), sampler.getCacheName())
                      : builder.add(entry.getCacheManagerSampler(), sampler.getCacheName());
            }
          }
        }
      }
      if (builder == null) {
        entities = new HashSet<CacheConfigEntityV2>(0);
      } else {
        entities = builder.build();
      }
    } finally {
      cacheManagerSamplerRepoLock.readLock().unlock();
    }

    return entities;
  }
コード例 #8
0
  @Override
  public Collection<CacheStatisticSampleEntity> createCacheStatisticSampleEntity(
      Set<String> cacheManagerNames, Set<String> cacheNames, Set<String> sampleNames) {
    CacheStatisticSampleEntityBuilder builder =
        CacheStatisticSampleEntityBuilder.createWith(sampleNames);

    cacheManagerSamplerRepoLock.readLock().lock();

    List<SamplerRepoEntry> disabledSamplerRepoEntries = new ArrayList<SamplerRepoEntry>();

    try {
      if (cacheManagerNames == null) {
        for (Map.Entry<String, SamplerRepoEntry> entry : cacheManagerSamplerRepo.entrySet()) {
          enableNonStopFor(entry.getValue(), false);
          disabledSamplerRepoEntries.add(entry.getValue());
          for (CacheSampler sampler : entry.getValue().getComprehensiveCacheSamplers(cacheNames)) {
            builder.add(sampler, entry.getKey());
          }
        }
      } else {
        for (String cmName : cacheManagerNames) {
          SamplerRepoEntry entry = cacheManagerSamplerRepo.get(cmName);
          if (entry != null) {
            enableNonStopFor(entry, false);
            disabledSamplerRepoEntries.add(entry);
            for (CacheSampler sampler : entry.getComprehensiveCacheSamplers(cacheNames)) {
              builder.add(sampler, cmName);
            }
          }
        }
      }

      return builder.build();
    } finally {
      for (SamplerRepoEntry samplerRepoEntry : disabledSamplerRepoEntries) {
        enableNonStopFor(samplerRepoEntry, true);
      }
      cacheManagerSamplerRepoLock.readLock().unlock();
    }
  }
コード例 #9
0
  /** {@inheritDoc} */
  @Override
  public Collection<CacheManagerEntity> createCacheManagerEntities(
      Set<String> cacheManagerNames, Set<String> attributes) {
    CacheManagerEntityBuilder builder = null;
    Collection<CacheManagerEntity> entities;
    cacheManagerSamplerRepoLock.readLock().lock();

    try {
      if (cacheManagerNames == null) {
        for (SamplerRepoEntry entry : cacheManagerSamplerRepo.values()) {
          builder =
              builder == null
                  ? CacheManagerEntityBuilder.createWith(entry.getCacheManagerSampler())
                  : builder.add(entry.getCacheManagerSampler());
        }
      } else {
        for (String cmName : cacheManagerNames) {
          SamplerRepoEntry entry = cacheManagerSamplerRepo.get(cmName);
          if (entry != null) {
            builder =
                builder == null
                    ? CacheManagerEntityBuilder.createWith(entry.getCacheManagerSampler())
                    : builder.add(entry.getCacheManagerSampler());
          }
        }
      }
      if (builder == null) entities = new HashSet<CacheManagerEntity>(0);
      else entities = attributes == null ? builder.build() : builder.add(attributes).build();
    } finally {
      cacheManagerSamplerRepoLock.readLock().unlock();
    }

    return entities;
  }