use of org.apache.ignite.client.ThinClientKubernetesAddressFinder in project ignite by apache.
the class ClientKubernetesPutGetExample method main.
/**
* Entry point.
*
* @param args Command line arguments.
*/
public static void main(String[] args) {
KubernetesConnectionConfiguration kcfg = new KubernetesConnectionConfiguration();
kcfg.setNamespace("ignite");
ClientConfiguration cfg = new ClientConfiguration();
cfg.setAddressesFinder(new ThinClientKubernetesAddressFinder(kcfg));
try (IgniteClient igniteClient = Ignition.startClient(cfg)) {
System.out.println();
System.out.println(">>> Thin client put-get example started.");
final String CACHE_NAME = "put-get-example";
ClientCache<Integer, Address> cache = igniteClient.getOrCreateCache(CACHE_NAME);
System.out.format(">>> Created cache [%s].\n", CACHE_NAME);
Integer key = 1;
Address val = new Address("1545 Jackson Street", 94612);
cache.put(key, val);
System.out.format(">>> Saved [%s] in the cache.\n", val);
Address cachedVal = cache.get(key);
System.out.format(">>> Loaded [%s] from the cache.\n", cachedVal);
}
}
use of org.apache.ignite.client.ThinClientKubernetesAddressFinder in project ignite by apache.
the class TestClusterClientConnection method testClientConnectsToCluster.
/**
*/
@Test
public void testClientConnectsToCluster() throws Exception {
mockServerResponse();
IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(), false);
IgniteEx crd = startGrid(cfg);
String crdAddr = crd.localNode().addresses().iterator().next();
mockServerResponse(crdAddr);
ClientConfiguration ccfg = new ClientConfiguration();
ccfg.setAddressesFinder(new ThinClientKubernetesAddressFinder(prepareConfiguration()));
IgniteClient client = Ignition.startClient(ccfg);
ClientCache cache = client.createCache("cache");
cache.put(1, 2);
assertEquals(2, cache.get(1));
}
Aggregations