-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the java client external kubernetes test
- Loading branch information
Showing
4 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.hazelcast</groupId> | ||
<artifactId>kubernetes-external-test-java</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>kubernetes-external-test-java</name> | ||
|
||
<properties> | ||
<jdk.version>17</jdk.version> | ||
<maven.compiler.release>${jdk.version}</maven.compiler.release> | ||
<maven.compiler.source>${jdk.version}</maven.compiler.source> | ||
<maven.compiler.target>${jdk.version}</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.hazelcast</groupId> | ||
<artifactId>hazelcast-enterprise-java-client</artifactId> | ||
<version>5.5.1-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.4.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>java</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<mainClass>KubernetesExternalTest</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
42 changes: 42 additions & 0 deletions
42
KubernetesExternalClients/java/src/main/java/KubernetesExternalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import com.hazelcast.client.HazelcastClient; | ||
import com.hazelcast.client.config.ClientConfig; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import com.hazelcast.map.IMap; | ||
|
||
import java.util.Random; | ||
import java.util.concurrent.ThreadLocalRandom; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* Kubernetes external test for thin java client | ||
*/ | ||
public class KubernetesExternalTest { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(KubernetesExternalTest.class.getName()); | ||
|
||
public static void main( String[] args ) throws InterruptedException { | ||
String externalIp = "<EXTERNAL-IP>"; | ||
|
||
ClientConfig clientConfig = new ClientConfig(); | ||
clientConfig.getNetworkConfig().addAddress(externalIp); | ||
|
||
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig); | ||
LOGGER.info("Successful connection!"); | ||
|
||
IMap<String, String> map = client.getMap("mapForJava"); | ||
LOGGER.info("Starting to fill the map with random entries."); | ||
|
||
Random random = ThreadLocalRandom.current(); | ||
for (int i = 0; i < 120; i++) { | ||
int randomKey = random.nextInt(100000); | ||
try { | ||
map.put("key" + randomKey, "value" + randomKey); | ||
} catch (Throwable exc) { | ||
LOGGER.warning("Put operation failed: " + exc); | ||
} | ||
int size = map.size(); | ||
LOGGER.info("Current map size: " + size); | ||
Thread.sleep(1000); | ||
} | ||
} | ||
} |