Search in sources :

Example 1 with KubernetesConnectionConfiguration

use of org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration in project ignite by apache.

the class KubernetesDiscoveryAbstractTest method getConfiguration.

/**
 */
protected IgniteConfiguration getConfiguration(String instanceName, Boolean clientMode) throws Exception {
    IgniteConfiguration cfg = getConfiguration();
    KubernetesConnectionConfiguration kccfg = prepareConfiguration();
    TcpDiscoveryKubernetesIpFinder ipFinder = new TcpDiscoveryKubernetesIpFinder(kccfg);
    TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
    discoverySpi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(discoverySpi);
    cfg.setGridLogger(log);
    cfg.setIgniteInstanceName(instanceName);
    cfg.setClientMode(clientMode);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryKubernetesIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder) KubernetesConnectionConfiguration(org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 2 with KubernetesConnectionConfiguration

use of org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration 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 3 with KubernetesConnectionConfiguration

use of org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration in project ignite by apache.

the class KubernetesServiceAddressResolverTest method prepareResolver.

/**
 */
private KubernetesServiceAddressResolver prepareResolver(boolean includeNotReadyAddresses) throws IOException {
    File account = File.createTempFile("kubernetes-test-account", "");
    FileWriter fw = new FileWriter(account);
    fw.write("account-token");
    fw.close();
    String accountFile = account.getAbsolutePath();
    KubernetesConnectionConfiguration cfg = new KubernetesConnectionConfiguration();
    cfg.setNamespace(namespace);
    cfg.setServiceName(service);
    cfg.setMasterUrl("https://localhost:" + mockServer.getLocalPort());
    cfg.setAccountToken(accountFile);
    cfg.setIncludeNotReadyAddresses(includeNotReadyAddresses);
    return new KubernetesServiceAddressResolver(cfg);
}
Also used : FileWriter(java.io.FileWriter) KubernetesConnectionConfiguration(org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration) File(java.io.File)

Example 4 with KubernetesConnectionConfiguration

use of org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration in project ignite by apache.

the class KubernetesDiscoveryAbstractTest method prepareConfiguration.

/**
 */
protected final KubernetesConnectionConfiguration prepareConfiguration() throws IOException {
    File account = File.createTempFile("kubernetes-test-account", "");
    FileWriter fw = new FileWriter(account);
    fw.write("account-token");
    fw.close();
    String accountFile = account.getAbsolutePath();
    KubernetesConnectionConfiguration cfg = new KubernetesConnectionConfiguration();
    cfg.setNamespace(namespace);
    cfg.setServiceName(service);
    cfg.setMasterUrl("https://localhost:" + mockServer.getLocalPort());
    cfg.setAccountToken(accountFile);
    return cfg;
}
Also used : FileWriter(java.io.FileWriter) KubernetesConnectionConfiguration(org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration) File(java.io.File)

Aggregations

KubernetesConnectionConfiguration (org.apache.ignite.kubernetes.configuration.KubernetesConnectionConfiguration)4 File (java.io.File)2 FileWriter (java.io.FileWriter)2 IgniteClient (org.apache.ignite.client.IgniteClient)1 ThinClientKubernetesAddressFinder (org.apache.ignite.client.ThinClientKubernetesAddressFinder)1 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 Address (org.apache.ignite.examples.model.Address)1 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)1 TcpDiscoveryKubernetesIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder)1