Search in sources :

Example 16 with StringConfiguration

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));
}
Also used : RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) Test(org.junit.Test)

Example 17 with StringConfiguration

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);
}
Also used : StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) RestMetricsClient(org.infinispan.client.rest.RestMetricsClient) Test(org.junit.Test)

Example 18 with StringConfiguration

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());
}
Also used : ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) StringConfiguration(org.infinispan.commons.configuration.StringConfiguration) CacheMeterBinder(io.micrometer.core.instrument.binder.cache.CacheMeterBinder) RemoteInfinispanCacheMeterBinderProvider(org.infinispan.spring.starter.remote.actuator.RemoteInfinispanCacheMeterBinderProvider) SpringCache(org.infinispan.spring.common.provider.SpringCache)

Aggregations

StringConfiguration (org.infinispan.commons.configuration.StringConfiguration)18 Test (org.junit.Test)8 RemoteCacheManager (org.infinispan.client.hotrod.RemoteCacheManager)6 BasicConfiguration (org.infinispan.commons.configuration.BasicConfiguration)3 TransactionManager (javax.transaction.TransactionManager)2 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)2 RestClient (org.infinispan.client.rest.RestClient)2 Test (org.testng.annotations.Test)2 CacheMeterBinder (io.micrometer.core.instrument.binder.cache.CacheMeterBinder)1 HashMap (java.util.HashMap)1 RemoteCacheManagerAdmin (org.infinispan.client.hotrod.RemoteCacheManagerAdmin)1 RemoteCacheConfiguration (org.infinispan.client.hotrod.configuration.RemoteCacheConfiguration)1 TransactionMode (org.infinispan.client.hotrod.configuration.TransactionMode)1 OperationsFactory (org.infinispan.client.hotrod.impl.operations.OperationsFactory)1 PingResponse (org.infinispan.client.hotrod.impl.operations.PingResponse)1 SingleHotRodServerTest (org.infinispan.client.hotrod.test.SingleHotRodServerTest)1 RestCacheClient (org.infinispan.client.rest.RestCacheClient)1 RestMetricsClient (org.infinispan.client.rest.RestMetricsClient)1 RestResponse (org.infinispan.client.rest.RestResponse)1 Json (org.infinispan.commons.dataconversion.internal.Json)1