You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sk...@apache.org on 2021/01/18 09:20:58 UTC
[ignite] branch master updated: IGNITE-13995 Updated
EncryptedCacheExample and removed deprecated methods usages. Fixes #8667
This is an automated email from the ASF dual-hosted git repository.
sk0x50 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 6690dec IGNITE-13995 Updated EncryptedCacheExample and removed deprecated methods usages. Fixes #8667
6690dec is described below
commit 6690decceaa982e511de3c8d01bc367deb4f4593
Author: Mirza Aliev <al...@gmail.com>
AuthorDate: Mon Jan 18 12:20:14 2021 +0300
IGNITE-13995 Updated EncryptedCacheExample and removed deprecated methods usages. Fixes #8667
Signed-off-by: Slava Koptilin <sl...@gmail.com>
---
.../examples/encryption/EncryptedCacheExample.java | 29 ++++++++++++----------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/examples/src/main/java/org/apache/ignite/examples/encryption/EncryptedCacheExample.java b/examples/src/main/java/org/apache/ignite/examples/encryption/EncryptedCacheExample.java
index 137d194..95513b6 100644
--- a/examples/src/main/java/org/apache/ignite/examples/encryption/EncryptedCacheExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/encryption/EncryptedCacheExample.java
@@ -23,6 +23,7 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
/**
@@ -30,6 +31,9 @@ import org.apache.ignite.configuration.CacheConfiguration;
* Data stored in persistence will be encrypted.
*/
public class EncryptedCacheExample {
+ /** Cache name. */
+ private static final String CACHE_NAME = "encrypted-accounts-caches";
+
/** */
public static void main(String[] args) {
System.out.println(">>> Starting cluster.");
@@ -40,9 +44,9 @@ public class EncryptedCacheExample {
try (Ignite ignite = Ignition.start("examples/config/encryption/example-encrypted-store.xml")) {
// Activate the cluster. Required to do if the persistent store is enabled because you might need
// to wait while all the nodes, that store a subset of data on disk, join the cluster.
- ignite.cluster().active(true);
+ ignite.cluster().state(ClusterState.ACTIVE);
- CacheConfiguration<Long, BankAccount> ccfg = new CacheConfiguration<>("encrypted-cache");
+ CacheConfiguration<Long, BankAccount> ccfg = new CacheConfiguration<>(CACHE_NAME);
// Enabling encryption for newly created cache.
ccfg.setEncryptionEnabled(true);
@@ -64,10 +68,10 @@ public class EncryptedCacheExample {
System.out.println(">>> Starting cluster again.");
// Starting cluster again.
try (Ignite ignite = Ignition.start("examples/config/encryption/example-encrypted-store.xml")) {
- ignite.cluster().active(true);
+ ignite.cluster().state(ClusterState.ACTIVE);
// We can obtain existing cache and load data from disk.
- IgniteCache<Long, BankAccount> cache = ignite.getOrCreateCache("encrypted-cache");
+ IgniteCache<Long, BankAccount> cache = ignite.getOrCreateCache(CACHE_NAME);
QueryCursor<Cache.Entry<Long, BankAccount>> cursor = cache.query(new ScanQuery<>());
@@ -79,7 +83,6 @@ public class EncryptedCacheExample {
", AccountName = " + entry.getValue().accountName +
", Balance = " + entry.getValue().balance);
}
-
}
}
@@ -87,17 +90,17 @@ public class EncryptedCacheExample {
* Test class with very secret data.
*/
private static class BankAccount {
- /**
- * Name.
- */
- private String accountName;
+ /** Name. */
+ private final String accountName;
+
+ /** Balance. */
+ private final long balance;
/**
- * Balance.
+ * Creates a new instance with the given account name and balance.
+ * @param accountName Account name.
+ * @param balance Balance.
*/
- private long balance;
-
- /** */
BankAccount(String accountName, long balance) {
this.accountName = accountName;
this.balance = balance;