Search in sources :

Example 46 with ClientConfiguration

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;
}
Also used : ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration)

Example 47 with ClientConfiguration

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration)

Example 48 with ClientConfiguration

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);
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) Address(org.apache.ignite.examples.model.Address) KubernetesConnectionConfiguration(org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration) ThinClientKubernetesAddressFinder(org.apache.ignite.client.ThinClientKubernetesAddressFinder) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration)

Example 49 with ClientConfiguration

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");
}
Also used : ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration)

Example 50 with ClientConfiguration

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);
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Connection(java.sql.Connection) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteEx(org.apache.ignite.internal.IgniteEx) QuerySqlFunction(org.apache.ignite.cache.query.annotations.QuerySqlFunction) SQLException(java.sql.SQLException) IgniteClient(org.apache.ignite.client.IgniteClient) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) JdbcThinAbstractSelfTest(org.apache.ignite.jdbc.thin.JdbcThinAbstractSelfTest) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) Test(org.junit.Test) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Consumer(java.util.function.Consumer) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignition(org.apache.ignite.Ignition) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CFG_URL_PREFIX(org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX) Phaser(java.util.concurrent.Phaser) Statement(java.sql.Statement) Pattern(java.util.regex.Pattern) DriverManager(java.sql.DriverManager) FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteClient(org.apache.ignite.client.IgniteClient) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) SQLException(java.sql.SQLException) JdbcThinAbstractSelfTest(org.apache.ignite.jdbc.thin.JdbcThinAbstractSelfTest) Test(org.junit.Test)

Aggregations

ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)83 Test (org.junit.Test)44 IgniteClient (org.apache.ignite.client.IgniteClient)42 Ignite (org.apache.ignite.Ignite)28 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)23 BinaryObject (org.apache.ignite.binary.BinaryObject)14 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)14 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)14 List (java.util.List)11 Ignition (org.apache.ignite.Ignition)10 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)10 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)9 Collections (java.util.Collections)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 IgniteBinary (org.apache.ignite.IgniteBinary)7 Connection (java.sql.Connection)6 Arrays (java.util.Arrays)6 Map (java.util.Map)6 Consumer (java.util.function.Consumer)6 ScanQuery (org.apache.ignite.cache.query.ScanQuery)6