* @throws Exception
*/
public static void createNewCaches(ModelControllerClient mcc, HashMap<String, String> serverProperties)
throws Exception {
final InfinispanJBossASClient client = new InfinispanJBossASClient(mcc);
final String cacheContainerName = RHQ_CACHE_CONTAINER;
String localCacheName = RHQ_CACHE;
if (!client.isCacheContainer(cacheContainerName)) {
ModelNode request = client.createNewCacheContainerRequest(cacheContainerName, localCacheName);
ModelNode results = client.execute(request);
if (!MessagingJBossASClient.isSuccess(results)) {
throw new FailureException(results, "Failed to create Cache container [" + cacheContainerName + "]");
} else {
LOG.info("Cache container [" + cacheContainerName + "] created");
}
} else {
LOG.info("Cache container [" + cacheContainerName + "] already exists, skipping the creation request");
}
if (!client.isLocalCache(cacheContainerName, localCacheName)) {
ModelNode request = client.createNewLocalCacheRequest(cacheContainerName, localCacheName, null, null, null,
null, null, null);
ModelNode results = client.execute(request);
if (!MessagingJBossASClient.isSuccess(results)) {
throw new FailureException(results, "Failed to create Local Cache [" + localCacheName + "]");
} else {
LOG.info("Local Cache [" + localCacheName + "] created");
}
} else {
LOG.info("Local Cache [" + localCacheName + "] already exists, skipping the creation request");
}
localCacheName = RHQ_REST_CACHE;
final long lifeSpan = 15 * 60 * 1000L; // 15min
final long maxIdle = 5 * 60 * 1000L; // 5min
if (!client.isLocalCache(cacheContainerName, localCacheName)) {
ModelNode request = client.createNewLocalCacheRequest(cacheContainerName, localCacheName, null, null, null,
lifeSpan, maxIdle, null);
ModelNode results = client.execute(request);
if (!MessagingJBossASClient.isSuccess(results)) {
throw new FailureException(results, "Failed to create Local Cache [" + localCacheName + "]");
} else {
LOG.info("Local Cache [" + localCacheName + "] created");
}