Giriş
Bu komut aslında bir shell script. Kodu şöyle. Yani altta Picocli kullanan bir java kodunu çalıştırıyor. $@ ile hz-cli script'ine geçilen tüm parametreler HazelcastCommandLine sınıfına geçiliyor
#!/bin/bash ... JAVA_OPTS_ARRAY=(\ $JDK_OPTS \ "-Dhazelcast.client.config=$HAZELCAST_CLIENT_CONFIG" \ $JVM_OPTIONS \ $JAVA_OPTS \ ) $JAVA "${JAVA_OPTS_ARRAY[@]}" -\ cp "$CLASSPATH" com.hazelcast.client.console.HazelcastCommandLine "$@"
Global seçenekler şöyle. Global seçenekler komutlardan önce gelmelidir
--ignore-version-mismatchIgnore check between client and server versions (by default they must have matching minor version)-t, --targets=[<cluster-name>@]<hostname>:<port>[,<hostname>:<port>]The cluster name and addresses to use if you want to connect to a cluster other than the one configured in the configuration file. At least one address is required. The cluster name is optional.-h, --helpShow this help message and exit.-V, --versionPrint version information and exit.-f, --config=<config>Optional path to a client config XML/YAML file. The default is to use config/hazelcast-client.xml.-v, --verbosityShow verbose logs and full stack trace of errors
Komutlar şöyle
help Displays help information about the specified commandcancel Cancels a running jobcluster Shows current cluster state and information about membersconsole Starts the console application for trying out in-memory datastructures of Hazelcast. It is not recommended for use inproduction.delete-snapshot Deletes a named snapshotlist-jobs Lists running jobs on the clusterlist-snapshots Lists exported snapshots on the clusterrestart Restarts a running jobresume Resumes a suspended jobsave-snapshot Exports a named snapshot from a job and optionally cancels itsql Starts the SQL shell [BETA]submit Submits a job to the clustersuspend Suspends a running job
cancel komutu
Örnek
Şöyle yaparız
> bin/hz-cli submit target/pulsar-example-1.0-SNAPSHOT.jar > bin/hz-cli cancel pulsar-message-counter > hz-stop
Örnek
Şöyle yaparız
> hz-cli cancel wonky
cluster komutu
Örnek
Şöyle yaparız
$ hz-cli cluster State: ACTIVE Version: 5.3.2 Size: 3 ADDRESS UUID [172.26.0.4]:5701 4c810f68-cadd-42d5-8bd1-8028abc1d389 [172.26.0.3]:5701 4d648b81-a541-432f-b2fe-241f84bb4c87 [172.26.0.2]:5701 68774596-6c1b-4246-9755-7bfdd09b60f9
console komutu
Console App uygulamasını başlatırhelp komutu
Global seçenekleri gösterir. Çıktısı şöyle.
$ bin/hz-cli --help Hazelcast 5.2.0 Usage: hz-cli [-hvV] [--ignore-version-mismatch] [-f=<config>] [-t= [<cluster-name>@]<hostname>:<port>[,<hostname>:<port>]] [COMMAND] Utility to perform operations on a Hazelcast cluster. By default it uses the file config/hazelcast-client.xml to configure the client connection. Global options are: --ignore-version-mismatch Ignore check between client and server versions (by default they must have matching minor version) -t, --targets=[<cluster-name>@]<hostname>:<port>[,<hostname>:<port>] The cluster name and addresses to use if you want to connect to a cluster other than the one configured in the configuration file. At least one address is required. The cluster name is optional. -h, --help Show this help message and exit. -V, --version Print version information and exit. -f, --config=<config> Optional path to a client config XML/YAML file. The default is to use config/hazelcast-client.xml. -v, --verbosity Show verbose logs and full stack trace of errors
list jobs komutu
Örnek
Şöyle yaparız
hz-cli -t $MEMBER_IP list-jobs
Örnek
Şöyle yaparız
> hz-cli list-jobs ID STATUS SUBMISSION TIME NAME 097e-6a3d-1e00-0001 RUNNING 2023-03-03T13:13:09.390 N/A
submit komutu
Örnek - n
Çıktısı şöyle
> hz-cli submit -n foo basic-hazelcast-jet-1.0-SNAPSHOT.jar Submitting JAR 'basic-hazelcast-jet-1.0-SNAPSHOT.jar' with arguments [] Using job name 'foo' The JAR didn't submit any jobs.
Örnek -- help
Çıktısı şöyle
$ hz-cli submit --help Usage:hz-cli submit [-v] [--ignore-version-mismatch] [-c=] [-n=] [-s=] [-t=[@]:[,:]] [...] Submits a job to the cluster The jar file to submit [...] Arguments to pass to the supplied jar file -c, --class= Fully qualified name of the main class inside the JAR file --ignore-version-mismatch Ignore check between client and server versions (by default they must have matching minor version) -n, --name= Name of the job -s, --snapshot= Name of the initial snapshot to start the job from -t, --targets=[@]:[,:] The cluster name and addresses to use if you want to connect to a cluster other than the one configured in the configuration file. At least one address is required. The cluster name is optional. -v, --verbosity Show verbose logs and full stack trace of errors
Aslında belirtilen jar'ın main sınıfını çalıştırır. Main sınıf' şöyle olduğu için smart olmayan bir tane Hazelcast client başlatır ve onu kullanarak job'ı yükler.
public static void main(String[] args) { Pipeline pipeline = ... HazelcastInstance hz = Hazelcast.bootstrappedInstance(); hz.getJet().newJob(pipeline); }
Örnek
Şöyle yaparız. Burada MANIFEST.MF dosyasında Main-Class alanına değer atandığı varsayılıyor. Böylece jar çalıştırılırken hangi class'tan başlayacağını belirtmeye gerek yok. Eğer bu alan tanımlı değilse --class seçeneği ile main sınıfı belirtmek gerekir.
$ hz-cli submit myfat.jar
Örnek - f seçeneği
Şöyle yaparız. Burada belirtilen xml kullanılıyor.
$ bin/hz-cli -f hazelcast-client.xml submit hello-world.jar Submitting JAR 'hello-world.jar' with arguments []
Örnek --class seçeneği
MANIFEST.MF dosyasında Main-Class alanına değer yoksa şöyle yaparız
$ hz-cli submit --class org.example.EvenNumberStream $PATH_TO_JAR_FILE
sql komutu
Örnek
Şöyle yaparız
sql> CREATE MAPPING people DATA CONNECTION "mysql";
Örnek
Şöyle yaparız
sql> CREATE OR REPLACE MAPPING mymap (__key INT, this VARCHAR) TYPE IMap OPTIONS ('keyFormat'='int','valueFormat'='varchar'); SELECT * FROM mymap;
Hiç yorum yok:
Yorum Gönder