Skip to content

Commit

Permalink
Add zookeeper example
Browse files Browse the repository at this point in the history
  • Loading branch information
qianmoQ committed Mar 20, 2021
1 parent 971133c commit 3a5e7d1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<artifactId>gcm-hive</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.edurt.gcm</groupId>
<artifactId>gcm-zookeeper</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.edurt.gcm.example.general;

import com.google.inject.Guice;
import com.google.inject.Inject;
import io.edurt.gcm.zookeeper.ZookeeperModule;
import io.edurt.gcm.zookeeper.client.ZookeeperClient;

public class ZookeeperExample
{
@Inject
private ZookeeperClient zookeeperClient;

public static void main(String[] args)
{
String classpath = ZookeeperExample.class.getResource("/general/zookeeper.properties").getPath();
ZookeeperExample instance = Guice.createInjector(new ZookeeperModule(classpath))
.getInstance(ZookeeperExample.class);
System.out.println(instance.zookeeperClient.getNode("localhost"));
}
}
5 changes: 5 additions & 0 deletions example/src/main/resources/general/zookeeper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
zookeeper.service=localhost:2181
zookeeper.session-timeout=5000
zookeeper.connection-timeout=5000
zookeeper.retry=3
zookeeper.namespace=default

0 comments on commit 3a5e7d1

Please sign in to comment.