Esempio n. 1
0
 private void checkForInvalidAttributes(String cacheManagerName, CacheManagerEntityV2 resource)
     throws ServiceExecutionException {
   boolean invalidAttributesFound = false;
   StringBuilder errorMessage =
       new StringBuilder("You are not allowed to update those attributes : ");
   if (resource.getName() != null && !resource.getName().equals(cacheManagerName)) {
     errorMessage.append("name ");
     invalidAttributesFound = true;
   }
   for (Map.Entry<String, Object> attribute : resource.getAttributes().entrySet()) {
     String key = attribute.getKey();
     if (!key.equals(SamplerRepoEntry.MAX_BYTES_LOCAL_DISK_STRING)
         && !key.equals(SamplerRepoEntry.MAX_BYTES_LOCAL_HEAP_STRING)) {
       errorMessage.append(key).append(" ");
       invalidAttributesFound = true;
     }
   }
   if (invalidAttributesFound) {
     errorMessage
         .append(". Only ")
         .append(SamplerRepoEntry.MAX_BYTES_LOCAL_DISK_STRING)
         .append(" and ")
         .append(SamplerRepoEntry.MAX_BYTES_LOCAL_HEAP_STRING)
         .append(" can be updated for a CacheManager.");
     throw new ServiceExecutionException(errorMessage.toString());
   }
 }
Esempio n. 2
0
  @Override
  public void updateCacheManager(String cacheManagerName, CacheManagerEntityV2 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();
    }
  }