Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions openmessaging-api/src/main/java/io/openmessaging/Future.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@
* @since OMS 1.0.0
*/
public interface Future<V> {
/**
* Attempts to cancel execution of this task. This attempt will
* fail if the task has already completed, has already been cancelled,
* or could not be cancelled for some other reason. If successful,
* and this task has not started when {@code cancel} is called,
* this task should never run. If the task has already started,
* then the {@code mayInterruptIfRunning} parameter determines
* whether the thread executing this task should be interrupted in
* an attempt to stop the task.
*
* <p>After this method returns, subsequent calls to {@link #isDone} will
* always return {@code true}. Subsequent calls to {@link #isCancelled}
* will always return {@code true} if this method returned {@code true}.
*
* @param mayInterruptIfRunning {@code true} if the thread executing this
* task should be interrupted; otherwise, in-progress tasks are allowed
* to complete
* @return {@code false} if the task could not be cancelled,
* typically because it has already completed normally;
* {@code true} otherwise
*/
boolean cancel(boolean mayInterruptIfRunning);

/**
* Returns {@code true} if this task was cancelled before it completed normally.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public interface KeyValue {
* @return the value in this {@code KeyValue} object with the specified key value
* @see #put(String, short)
*/
int getShort(String key);
short getShort(String key);

/**
* Searches for the {@code short} property with the specified key in this {@code KeyValue} object. If the key is not
Expand All @@ -93,7 +93,7 @@ public interface KeyValue {
* @return the value in this {@code KeyValue} object with the specified key value
* @see #put(String, short)
*/
int getShort(String key, short defaultValue);
short getShort(String key, short defaultValue);

/**
* Searches for the {@code int} property with the specified key in this {@code KeyValue} object. If the key is not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public interface OMSBuiltinKeys {
*/
String ACCOUNT_ID = "ACCOUNT_ID";

/**
* The {@code ACCOUNT_KEY} key shows the specified account key in OMS attribute.
*/
String ACCOUNT_KEY = "ACCOUNT_KEY";

/**
* The {@code REGION} key shows the specified region in OMS driver schema.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ public class DefaultKeyValue implements KeyValue {
private Map<String, String> properties;

@Override
public int getShort(String key) {
return 0;
public short getShort(String key) {
if (!properties.containsKey(key)) {
return 0;
}
return Short.valueOf(properties.get(key));
}

@Override
public int getShort(String key, short defaultValue) {
return 0;
public short getShort(String key, short defaultValue) {
return properties.containsKey(key) ? getShort(key) : defaultValue;
}

@Override
Expand Down