Skip to content

Commit 941bda1

Browse files
authored
Merge pull request #1 from openmessaging/master
merge
2 parents fe5e4ad + de8f6de commit 941bda1

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

openmessaging-api/src/main/java/io/openmessaging/Future.java

+23
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,29 @@
3232
* @since OMS 1.0.0
3333
*/
3434
public interface Future<V> {
35+
/**
36+
* Attempts to cancel execution of this task. This attempt will
37+
* fail if the task has already completed, has already been cancelled,
38+
* or could not be cancelled for some other reason. If successful,
39+
* and this task has not started when {@code cancel} is called,
40+
* this task should never run. If the task has already started,
41+
* then the {@code mayInterruptIfRunning} parameter determines
42+
* whether the thread executing this task should be interrupted in
43+
* an attempt to stop the task.
44+
*
45+
* <p>After this method returns, subsequent calls to {@link #isDone} will
46+
* always return {@code true}. Subsequent calls to {@link #isCancelled}
47+
* will always return {@code true} if this method returned {@code true}.
48+
*
49+
* @param mayInterruptIfRunning {@code true} if the thread executing this
50+
* task should be interrupted; otherwise, in-progress tasks are allowed
51+
* to complete
52+
* @return {@code false} if the task could not be cancelled,
53+
* typically because it has already completed normally;
54+
* {@code true} otherwise
55+
*/
56+
boolean cancel(boolean mayInterruptIfRunning);
57+
3558
/**
3659
* Returns {@code true} if this task was cancelled before it completed normally.
3760
*

openmessaging-api/src/main/java/io/openmessaging/KeyValue.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public interface KeyValue {
8383
* @return the value in this {@code KeyValue} object with the specified key value
8484
* @see #put(String, short)
8585
*/
86-
int getShort(String key);
86+
short getShort(String key);
8787

8888
/**
8989
* Searches for the {@code short} property with the specified key in this {@code KeyValue} object. If the key is not
@@ -94,7 +94,7 @@ public interface KeyValue {
9494
* @return the value in this {@code KeyValue} object with the specified key value
9595
* @see #put(String, short)
9696
*/
97-
int getShort(String key, short defaultValue);
97+
short getShort(String key, short defaultValue);
9898

9999
/**
100100
* Searches for the {@code int} property with the specified key in this {@code KeyValue} object. If the key is not

openmessaging-api/src/main/java/io/openmessaging/OMSBuiltinKeys.java

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public interface OMSBuiltinKeys {
4141
*/
4242
String ACCOUNT_ID = "ACCOUNT_ID";
4343

44+
/**
45+
* The {@code ACCOUNT_KEY} key shows the specified account key in OMS attribute.
46+
*/
47+
String ACCOUNT_KEY = "ACCOUNT_KEY";
48+
4449
/**
4550
* The {@code REGION} key shows the specified region in OMS driver schema.
4651
*/

openmessaging-api/src/main/java/io/openmessaging/internal/DefaultKeyValue.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ public class DefaultKeyValue implements KeyValue {
3232
private Map<String, String> properties;
3333

3434
@Override
35-
public int getShort(String key) {
36-
return 0;
35+
public short getShort(String key) {
36+
if (!properties.containsKey(key)) {
37+
return 0;
38+
}
39+
return Short.valueOf(properties.get(key));
3740
}
3841

3942
@Override
40-
public int getShort(String key, short defaultValue) {
41-
return 0;
43+
public short getShort(String key, short defaultValue) {
44+
return properties.containsKey(key) ? getShort(key) : defaultValue;
4245
}
4346

4447
@Override

0 commit comments

Comments
 (0)