use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class JavaThinClient method transactionConfiguration.
@Test
void transactionConfiguration() {
// tag::transaction-config[]
ClientConfiguration cfg = new ClientConfiguration();
cfg.setAddresses("localhost:10800");
cfg.setTransactionConfiguration(new ClientTransactionConfiguration().setDefaultTxTimeout(10000).setDefaultTxConcurrency(TransactionConcurrency.OPTIMISTIC).setDefaultTxIsolation(TransactionIsolation.REPEATABLE_READ));
IgniteClient client = Ignition.startClient(cfg);
// end::transaction-config[]
ClientCache cache = client.createCache(new ClientCacheConfiguration().setName("test").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
// tag::tx-custom-properties[]
ClientTransactions tx = client.transactions();
try (ClientTransaction t = tx.txStart(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ)) {
cache.put(1, "new value");
t.commit();
}
// end::tx-custom-properties[]
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class BinaryMetadataRegisterClassTest method afterTest.
/**
* {@inheritDoc}
*/
@Override
protected void afterTest() throws Exception {
stopAllGrids();
for (IgniteClient thinClient : thinClients) thinClient.close();
super.afterTest();
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class K8s method connectThinClientWithConfiguration.
public static void connectThinClientWithConfiguration() throws Exception {
// tag::connectThinClientWithKubernetesConfiguration[]
KubernetesConnectionConfiguration kcfg = new KubernetesConnectionConfiguration();
kcfg.setNamespace("ignite");
kcfg.setServiceName("ignite-service");
ClientConfiguration ccfg = new ClientConfiguration();
ccfg.setAddressesFinder(new ThinClientKubernetesAddressFinder(kcfg));
IgniteClient client = Ignition.startClient(cfg);
ClientCache<Integer, String> cache = client.getOrCreateCache("test_cache");
cache.put(1, "first test value");
System.out.println(cache.get(1));
client.close();
// end::connectThinClientWithKubernetesConfiguration[]
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class K8s method connectThinClient.
public static void connectThinClient() throws Exception {
// tag::connectThinClient[]
ClientConfiguration cfg = new ClientConfiguration().setAddresses("13.86.186.145:10800");
IgniteClient client = Ignition.startClient(cfg);
ClientCache<Integer, String> cache = client.getOrCreateCache("test_cache");
cache.put(1, "first test value");
System.out.println(cache.get(1));
client.close();
// end::connectThinClient[]
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ClientPutGetExample method main.
/**
* Entry point.
*
* @param args Command line arguments.
*/
public static void main(String[] args) {
ClientConfiguration cfg = new ClientConfiguration().setAddresses("127.0.0.1:10800");
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);
} catch (ClientException e) {
System.err.println(e.getMessage());
}
}
Aggregations