Skip to content

Commit d70b1c4

Browse files
authored
chore: regfine javadoc (#74)
1 parent ce9aa59 commit d70b1c4

26 files changed

Lines changed: 291 additions & 88 deletions

README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44
![License](https://img.shields.io/badge/license-Apache--2.0-green.svg)
55
[![Maven Central](https://img.shields.io/maven-central/v/io.greptime/greptimedb-ingester.svg?label=maven%20central)](https://central.sonatype.com/search?q=io.greptime&name=ingester-all)
66

7-
A Java ingester for GreptimeDB, which is compatible with GreptimeDB protocol and lightweight.
7+
A lightweight Java ingester for GreptimeDB designed for high-throughput data writing. It utilizes the gRPC protocol to provide a non-blocking, purely asynchronous API that is easy to use and integrate into your applications.
88

9-
## Features
9+
## Documentation
10+
- [API Reference](https://javadoc.io/doc/io.greptime/ingester-protocol/latest/index.html)
11+
- [Examples](https://github.com/GreptimeTeam/greptimedb-ingester-java/tree/main/ingester-example)
1012

11-
- SPI-based extensible network transport layer; provides the default implementation by using the
12-
gRPC framework
13-
- Non-blocking, purely asynchronous API, easy to use
14-
- Automatically collects various performance metrics by default. Users can then configure them and
15-
write to local files
16-
- Users can take in-memory snapshots of critical objects, configure them, and write to local files.
17-
This is helpful when troubleshooting complex issues
18-
19-
## Javadoc
20-
- [ingester-protocol](https://javadoc.io/doc/io.greptime/ingester-protocol/latest/index.html)
13+
# Features
14+
TODO

ingester-common/src/main/java/io/greptime/common/util/ExecutorServiceHelper.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public final class ExecutorServiceHelper {
3030

3131
/**
3232
* @see #shutdownAndAwaitTermination(ExecutorService, long)
33+
*
34+
* @param pool the executor service to shutdown
35+
* @return true if the executor service is shutdown successfully, false otherwise
3336
*/
3437
public static boolean shutdownAndAwaitTermination(ExecutorService pool) {
3538
return shutdownAndAwaitTermination(pool, 1000);
@@ -40,6 +43,10 @@ public static boolean shutdownAndAwaitTermination(ExecutorService pool) {
4043
* phases, first by calling {@code shutdown} to reject incoming tasks,
4144
* and then calling {@code shutdownNow}, if necessary, to cancel any
4245
* lingering tasks.
46+
*
47+
* @param pool the executor service to shutdown
48+
* @param timeoutMillis the timeout in milliseconds
49+
* @return true if the executor service is shutdown successfully, false otherwise
4350
*/
4451
public static boolean shutdownAndAwaitTermination(ExecutorService pool, long timeoutMillis) {
4552
if (pool == null) {

ingester-common/src/main/java/io/greptime/common/util/Files.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public static void fsync(File file) throws IOException {
5050
* Creates the directory named by this pathname if not exists.
5151
*
5252
* @param path pathname
53+
* @throws IOException if an I/O error occurs
5354
*/
5455
public static void mkdirIfNotExists(String path) throws IOException {
5556
File dir = Paths.get(path).toFile().getAbsoluteFile();

ingester-common/src/main/java/io/greptime/common/util/MetricsUtil.java

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,71 +82,97 @@ public static void reportImmediately() {
8282
}
8383

8484
/**
85-
* Return the global registry of metric instances.
85+
* Gets the global registry of metric instances.
86+
*
87+
* @return the global registry of metric instances
8688
*/
8789
public static MetricRegistry metricRegistry() {
8890
return METRIC_REGISTRY;
8991
}
9092

9193
/**
92-
* Return the {@link Meter} registered under this name; or create
94+
* Gets the {@link Meter} registered under this name; or create
9395
* and register a new {@link Meter} if none is registered.
96+
*
97+
* @param name the name of the metric
98+
* @return the {@link Meter} registered under this name
9499
*/
95100
public static Meter meter(Object name) {
96101
return METRIC_REGISTRY.meter(named(name));
97102
}
98103

99104
/**
100-
* Return the {@link Meter} registered under this name; or create
105+
* Gets the {@link Meter} registered under this name; or create
101106
* and register a new {@link Meter} if none is registered.
107+
*
108+
* @param names the names of the metric
109+
* @return the {@link Meter} registered under this name
102110
*/
103111
public static Meter meter(Object... names) {
104112
return METRIC_REGISTRY.meter(named(names));
105113
}
106114

107115
/**
108-
* Return the {@link Timer} registered under this name; or create
116+
* Gets the {@link Timer} registered under this name; or create
109117
* and register a new {@link Timer} if none is registered.
118+
*
119+
* @param name the name of the metric
120+
* @return the {@link Timer} registered under this name
110121
*/
111122
public static Timer timer(Object name) {
112123
return METRIC_REGISTRY.timer(named(name));
113124
}
114125

115126
/**
116-
* Return the {@link Timer} registered under this name; or create
127+
* Gets the {@link Timer} registered under this name; or create
117128
* and register a new {@link Timer} if none is registered.
129+
*
130+
* @param names the names of the metric
131+
* @return the {@link Timer} registered under this name
118132
*/
119133
public static Timer timer(Object... names) {
120134
return METRIC_REGISTRY.timer(named(names));
121135
}
122136

123137
/**
124-
* Return the {@link Counter} registered under this name; or create
138+
* Gets the {@link Counter} registered under this name; or create
125139
* and register a new {@link Counter} if none is registered.
140+
*
141+
* @param name the name of the metric
142+
* @return the {@link Counter} registered under this name
126143
*/
127144
public static Counter counter(Object name) {
128145
return METRIC_REGISTRY.counter(named(name));
129146
}
130147

131148
/**
132-
* Return the {@link Counter} registered under this name; or create
149+
* Gets the {@link Counter} registered under this name; or create
133150
* and register a new {@link Counter} if none is registered.
151+
*
152+
* @param names the names of the metric
153+
* @return the {@link Counter} registered under this name
134154
*/
135155
public static Counter counter(Object... names) {
136156
return METRIC_REGISTRY.counter(named(names));
137157
}
138158

139159
/**
140-
* Return the {@link Histogram} registered under this name; or create
160+
* Gets the {@link Histogram} registered under this name; or create
141161
* and register a new {@link Histogram} if none is registered.
162+
*
163+
* @param name the name of the metric
164+
* @return the {@link Histogram} registered under this name
142165
*/
143166
public static Histogram histogram(Object name) {
144167
return METRIC_REGISTRY.histogram(named(name));
145168
}
146169

147170
/**
148-
* Return the {@link Histogram} registered under this name; or create
171+
* Gets the {@link Histogram} registered under this name; or create
149172
* and register a new {@link Histogram} if none is registered.
173+
*
174+
* @param names the names of the metric
175+
* @return the {@link Histogram} registered under this name
150176
*/
151177
public static Histogram histogram(Object... names) {
152178
return METRIC_REGISTRY.histogram(named(names));

ingester-common/src/main/java/io/greptime/common/util/ObjectPool.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,37 @@
2222
public interface ObjectPool<T> {
2323

2424
/**
25-
* Get an object from the pool.
25+
* Gets an object from the pool.
26+
*
27+
* @return an object from the pool
2628
*/
2729
T getObject();
2830

2931
/**
30-
* Return the object to the pool. The caller should not use the object beyond this point.
32+
* Returns the object to the pool. The caller should not use the object beyond this point.
33+
*
34+
* @param returned the object to return to the pool
3135
*/
3236
void returnObject(T returned);
3337

3438
/**
3539
* Defines a resource, and the way to create and destroy instances of it.
40+
*
41+
* @param <T> the type of the resource
3642
*/
3743
interface Resource<T> {
3844

3945
/**
40-
* Create a new instance of the resource.
46+
* Creates a new instance of the resource.
47+
*
48+
* @return a new instance of the resource
4149
*/
4250
T create();
4351

4452
/**
45-
* Destroy the given instance.
53+
* Destroys the given instance.
54+
*
55+
* @param instance the instance to destroy
4656
*/
4757
void close(T instance);
4858
}

ingester-common/src/main/java/io/greptime/common/util/Platform.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ public class Platform {
3535
private static final boolean IS_MAC = isMac0();
3636

3737
/**
38-
* Return {@code true} if the JVM is running on Windows
38+
* Checks if the JVM is running on Windows.
39+
*
40+
* @return {@code true} if the JVM is running on Windows
3941
*/
4042
public static boolean isWindows() {
4143
return IS_WINDOWS;
4244
}
4345

4446
/**
45-
* Return {@code true} if the JVM is running on Mac OSX
47+
* Checks if the JVM is running on Mac OSX.
48+
*
49+
* @return {@code true} if the JVM is running on Mac OSX
4650
*/
4751
public static boolean isMac() {
4852
return IS_MAC;

ingester-common/src/main/java/io/greptime/common/util/SerializingExecutor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public SerializingExecutor(String name, Thread.UncaughtExceptionHandler uncaught
6666
* under a lock of your own, but don't want the tasks to be run under
6767
* your lock (for fear of deadlock). You can call this method in the
6868
* lock, and call {@link #drain} outside the lock.
69+
*
70+
* @param task the task to add
6971
*/
7072
public final void executeLater(Runnable task) {
7173
this.queue.add(Ensures.ensureNonNull(task, "null `task`"));

ingester-common/src/main/java/io/greptime/common/util/SharedScheduledPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.concurrent.ScheduledExecutorService;
2020

2121
/**
22-
* Like rust: pub type SharedScheduledPool = RcObjectPool<ScheduledExecutorService>
22+
* Like rust: {@code pub type SharedScheduledPool = RcObjectPool<ScheduledExecutorService>}
2323
*/
2424
public class SharedScheduledPool extends RcObjectPool<ScheduledExecutorService> {
2525

ingester-common/src/main/java/io/greptime/common/util/SharedThreadPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.concurrent.ExecutorService;
2020

2121
/**
22-
* Like rust: pub type SharedThreadPool = RcObjectPool<ExecutorService>
22+
* Like rust: {@code pub type SharedThreadPool = RcObjectPool<ExecutorService>}
2323
*/
2424
public class SharedThreadPool extends RcObjectPool<ExecutorService> {
2525

ingester-common/src/main/java/io/greptime/common/util/Strings.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,30 @@ public static String toString(Object obj) {
3333
}
3434

3535
/**
36-
* Returns the given string if it is non-null; the empty string otherwise.
36+
* Converts a null string to an empty string.
37+
*
38+
* @param string the string to check
39+
* @return the given string if it is non-null; the empty string otherwise
3740
*/
3841
public static String nullToEmpty(String string) {
3942
return (string == null) ? "" : string;
4043
}
4144

4245
/**
43-
* Returns the given string if it is nonempty; {@code null} otherwise.
46+
* Converts an empty string to a null string.
47+
*
48+
* @param string the string to check
49+
* @return the given string if it is nonempty; {@code null} otherwise
4450
*/
4551
public static String emptyToNull(String string) {
4652
return isNullOrEmpty(string) ? null : string;
4753
}
4854

4955
/**
50-
* Returns {@code true} if the given string is null or is the empty string.
56+
* Checks if the given string is null or is the empty string.
57+
*
58+
* @param str the string to check
59+
* @return {@code true} if the given string is null or is the empty string
5160
*/
5261
public static boolean isNullOrEmpty(String str) {
5362
return str == null || str.isEmpty();
@@ -63,6 +72,9 @@ public static boolean isNullOrEmpty(String str) {
6372
* Strings.isBlank("bob") = false
6473
* Strings.isBlank(" bob ") = false
6574
* ```
75+
*
76+
* @param str the string to check
77+
* @return {@code true} if the given string is null, empty or whitespace only
6678
*/
6779
public static boolean isBlank(String str) {
6880
int strLen;
@@ -86,6 +98,9 @@ public static boolean isBlank(String str) {
8698
* Strings.isNotBlank("bob") = true
8799
* Strings.isNotBlank(" bob ") = true
88100
* ```
101+
*
102+
* @param str the string to check
103+
* @return {@code true} if the given string is not null, empty or whitespace only
89104
*/
90105
public static boolean isNotBlank(String str) {
91106
return !isBlank(str);
@@ -104,6 +119,10 @@ public static boolean isNotBlank(String str) {
104119
* Strings.split("a:b:c", '.') = ["a:b:c"]
105120
* Strings.split("a b c", ' ') = ["a", "b", "c"]
106121
* ```
122+
*
123+
* @param str the string to split
124+
* @param separator the separator
125+
* @return an array of strings
107126
*/
108127
public static String[] split(String str, char separator) {
109128
return split(str, separator, false);
@@ -129,6 +148,11 @@ public static String[] split(String str, char separator) {
129148
* Strings.split(" a b c", ' ', true) = ["", "", a", "b", "c"]
130149
* Strings.split(" a b c ", ' ', true) = ["", a", "b", "c", ""]
131150
* ```
151+
*
152+
* @param str the string to split
153+
* @param separator the separator
154+
* @param preserveAllTokens {@code true} if all tokens should be preserved, including empty tokens created by adjacent separators
155+
* @return an array of strings
132156
*/
133157
public static String[] split(String str, char separator, boolean preserveAllTokens) {
134158
if (str == null) {

0 commit comments

Comments
 (0)