use of org.infinispan.commons.configuration.StringConfiguration in project infinispan by infinispan.
the class HotRodAdmin method testCreateDeleteTemplate.
@Test
public void testCreateDeleteTemplate() {
RemoteCacheManager rcm = SERVER_TEST.hotrod().createRemoteCacheManager();
String templateName = "template";
String template = String.format("<infinispan><cache-container><distributed-cache name=\"%s\"/></cache-container></infinispan>", templateName);
rcm.administration().createTemplate(templateName, new StringConfiguration(template));
RemoteCache<String, String> cache = rcm.administration().createCache("testCreateDeleteTemplate", templateName);
cache.put("k", "v");
assertNotNull(cache.get("k"));
rcm.administration().removeTemplate(templateName);
Exceptions.expectException(HotRodClientException.class, () -> rcm.administration().createCache("anotherCache", templateName));
}
use of org.infinispan.commons.configuration.StringConfiguration in project infinispan by infinispan.
the class XSiteRestMetricsOperations method testSiteStatus.
@Test
public void testSiteStatus() throws Exception {
String lonXML = String.format(LON_CACHE_XML_CONFIG, SERVER_TEST.getMethodName());
String nycXML = String.format(NYC_CACHE_XML_CONFIG, SERVER_TEST.getMethodName());
RestClient client = SERVER_TEST.rest(LON).withServerConfiguration(new StringConfiguration(lonXML)).create();
RestMetricsClient metricsClient = client.metrics();
// create cache in NYC
SERVER_TEST.rest(NYC).withServerConfiguration(new StringConfiguration(nycXML)).create();
String statusMetricName = "cache_manager_default_cache_" + SERVER_TEST.getMethodName() + "_x_site_admin_nyc_status";
try (RestResponse response = sync(metricsClient.metrics(true))) {
assertEquals(200, response.getStatus());
RestMetricsResource.checkIsOpenmetrics(response.contentType());
assertTrue(response.getBody().contains("# TYPE vendor_" + statusMetricName + " gauge\n"));
}
assertSiteStatusMetrics(metricsClient, statusMetricName, 1);
try (RestResponse response = sync(client.cacheManager("default").takeOffline(NYC))) {
assertEquals(200, response.getStatus());
}
assertSiteStatusMetrics(metricsClient, statusMetricName, 0);
}
use of org.infinispan.commons.configuration.StringConfiguration in project infinispan by infinispan.
the class RemoteCacheMetricBinderTest method binder.
@Override
public CacheMeterBinder binder() {
org.infinispan.configuration.cache.ConfigurationBuilder serverBuilder = new org.infinispan.configuration.cache.ConfigurationBuilder();
serverBuilder.clustering().cacheMode(CacheMode.DIST_SYNC);
StringConfiguration stringConfiguration = new StringConfiguration(serverBuilder.build().toStringConfiguration("mycache"));
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
clientBuilder.statistics().enable();
clientBuilder.security().authentication().username(TestUser.ADMIN.getUser()).password(TestUser.ADMIN.getPassword());
RemoteCacheManager remoteCacheManager = infinispanServerExtension.hotrod().withClientConfiguration(clientBuilder).createRemoteCacheManager();
cache = remoteCacheManager.administration().getOrCreateCache("mycache", stringConfiguration);
RemoteInfinispanCacheMeterBinderProvider remoteInfinispanCacheMeterBinderProvider = new RemoteInfinispanCacheMeterBinderProvider();
return (CacheMeterBinder) remoteInfinispanCacheMeterBinderProvider.getMeterBinder(new SpringCache(cache), emptyList());
}
Aggregations