Generate TimeUUID in Talend

Five Stars

Generate TimeUUID in Talend

I am trying to generate a timeuuid (i.e., version 1 UUID) in Talend to use when loading data into Cassandra.

 

I would like to do something similar to the java.util.UUID.randomUUID() function that generates a version 4 UUID, except that I need to generate a version 1 UUID. I don't want to have to create a connection to a Cassandra instance and use "select now()" everytime I need to generate a new timeuuid.

 

I understand that the Datastax Cassandra Java driver includes a "UUIDs" class that can be used to do this, but I can't seem to get the driver installed properly into Talend. I have tried using the tLoadLibrary component with no luck. I have also tried adding the library files to the my custom routine. And I've tried adding the external jars through the preferences.

 

I am at the point where I'm no longer getting compile errors, but I'm still getting a run time error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/datastax/driver/core/utils/UUIDs
...
Caused by: java.lang.ClassNotFoundException: com.datastax.driver.core.utils.UUIDs
...

Below is the code I'm using to make the function call:

String tb = com.datastax.driver.core.utils.UUIDs.timeBased().toString();
System.out.println(tb);

If anyone has had success with getting the Datastax Cassandra Java driver properly installed into Talend (or another simple way of generating a timeuuid) and can help, then that would be great.

 

I am using Talend Open Studio for Big Data v6.3.

I am developing on a machine with Windows 10.

Jobs are deployed on a Linux server.

Community Manager

Re: Generate TimeUUID in Talend

Hello
Maybe you don't install the right driver, I have installed this jar and it fixes the error.
http://central.maven.org/maven2/com/datastax/cassandra/cassandra-driver-core/3.3.2/cassandra-driver-...

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: Generate TimeUUID in Talend

I originally tried it with the cassandra-driver-core-3.3.0.jar file, but I also just tried it with the one you supplied (3.3.2) and I'm still getting the same error. Can you walk me through what you did to install the jar file and make the function call?

Community Manager

Re: Generate TimeUUID in Talend

I use a tLibraryLoad to load the jar and execute the Java code on a tJava component.
String tb = com.datastax.driver.core.utils.UUIDs.timeBased().toString();
System.out.println(tb);

----------------------------------------------------------
Talend | Data Agility for Modern Business
Highlighted
Five Stars

Re: Generate TimeUUID in Talend

Strange. That is the same thing I'm doing, but I still get a class not found exception.

 

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
	at com.datastax.driver.core.utils.UUIDs.<clinit>(UUIDs.java:66)
	...
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 5 more
Four Stars

Re: Generate TimeUUID in Talend

I am having similar issue.

 

Downloaded the Cassandra Driver jar and calling using t library component and used below in tjava row:

row2.adddate = com.datastax.driver.core.utils.UUIDs.timeBased().toString();

 

Getting Below Error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/util/concurrent/AsyncFunction
at merchandising_cpm.j_etl10029d_cpm_t3464_spn_itm_extract_db2_stg_0_1.J_ETL10029D_CPM_T3464_Spn_Itm_Extract_DB2_Stg.tDBInput_1Process(J_ETL10029D_CPM_T3464_Spn_Itm_Extract_DB2_Stg.java:3011)
at merchandising_cpm.j_etl10029d_cpm_t3464_spn_itm_extract_db2_stg_0_1.J_ETL10029D_CPM_T3464_Spn_Itm_Extract_DB2_Stg.runJobInTOS(J_ETL10029D_CPM_T3464_Spn_Itm_Extract_DB2_Stg.java:5586)
at merchandising_cpm.j_etl10029d_cpm_t3464_spn_itm_extract_db2_stg_0_1.J_ETL10029D_CPM_T3464_Spn_Itm_Extract_DB2_Stg.main(J_ETL10029D_CPM_T3464_Spn_Itm_Extract_DB2_Stg.java:5306)
Caused by: java.lang.ClassNotFoundException: com.google.common.util.concurrent.AsyncFunction
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more

Four Stars

Re: Generate TimeUUID in Talend

Solution provided above worked, when i used the same in Java row component.

row3.adddate = com.datastax.driver.core.utils.UUIDs.timeBased().toString();

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

Talend Integration with Databricks

Take a look at this video about Talend Integration with Databricks

Watch Now

How to Modernize Your Cloud Platform for Big Data Analytics With Talend and Micr...

Learn how<SPAN>to modernize your Cloud Platform for Big Data Analytics with Talend and Microsoft Azure</SPAN>

Read