use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class MultipleSSLContextsTest method clientConfiguration.
/**
* @param addr Address of a node to connect to.
* @return {@link ClientConfiguration} that can be used to start a thin client.
*/
private ClientConfiguration clientConfiguration(String addr) {
ClientConfiguration clientCfg = new ClientConfiguration().setAddresses(addr);
clientCfg.setSslContextFactory(thinClientSSLFactory());
clientCfg.setSslMode(SslMode.REQUIRED);
return clientCfg;
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class IgniteThinClient method start.
/**
*/
public IgniteClient start(BenchmarkConfiguration cfg, String host) throws Exception {
IgniteBenchmarkArguments args = new IgniteBenchmarkArguments();
BenchmarkUtils.jcommander(cfg.commandLineArguments(), args, "<ignite-node>");
IgniteBiTuple<IgniteConfiguration, ? extends ApplicationContext> tup = loadConfiguration(args.configuration());
IgniteConfiguration c = tup.get1();
assert c != null;
if (args.cleanWorkDirectory())
FileUtils.cleanDirectory(U.workDirectory(c.getWorkDirectory(), c.getIgniteHome()));
ClientConfiguration clCfg = new ClientConfiguration();
String hostPort = host + ":10800";
BenchmarkUtils.println(String.format("Using for connection address: %s", hostPort));
clCfg.setAddresses(hostPort);
client = Ignition.startClient(clCfg);
return client;
}
use of org.apache.ignite.configuration.ClientConfiguration 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.configuration.ClientConfiguration in project ignite by apache.
the class ClientSizeCacheCreationDestructionTest method beforeTest.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTest() throws Exception {
super.beforeTest();
srv = startGrid("server");
thickClient = startClientGrid(1);
thinClient = Ignition.startClient(new ClientConfiguration().setAddresses("127.0.0.1:10800"));
jdbcConn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10800");
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class RunningQueryInfoCheckInitiatorTest method testThinClientInitiatorId.
/**
* @throws Exception If failed.
*/
@Test
public void testThinClientInitiatorId() throws Exception {
Consumer<String> sqlExec = sql -> {
GridTestUtils.runAsync(() -> {
try (IgniteClient cli = Ignition.startClient(new ClientConfiguration().setAddresses("127.0.0.1:" + clientPort(grid(0))).setUserName("ignite").setUserPassword("ignite"))) {
cli.query(new SqlFieldsQuery(sql)).getAll();
} catch (Exception e) {
log.error("Unexpected exception", e);
}
});
};
Consumer<String> initiatorChecker = initiatorId -> {
assertTrue("Invalid initiator ID: " + initiatorId, Pattern.compile("cli:127\\.0\\.0\\.1:[0-9]+@ignite").matcher(initiatorId).matches());
};
check(sqlExec, initiatorChecker);
}
Aggregations