-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vertx meta data changes final (#114)
* vertx meta data changes * vertx meta data changes
- Loading branch information
1 parent
f79249c
commit 3d5c926
Showing
13 changed files
with
707 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ | |
* @author <a href="mailto:[email protected]">Ruslan Sennov</a> | ||
*/ | ||
@DataObject | ||
public class Service { | ||
public class Service implements TxnResult { | ||
|
||
private static final String NODE = "Node"; | ||
private static final String ADDRESS = "Address"; | ||
|
@@ -44,6 +44,8 @@ public class Service { | |
private static final String SERVICE_ADDRESS = "ServiceAddress"; | ||
private static final String SERVICE_META = "ServiceMeta"; | ||
private static final String SERVICE_PORT = "ServicePort"; | ||
private static final String CREATE_INDEX = "CreateIndex"; | ||
private static final String MODIFY_INDEX = "ModifyIndex"; | ||
|
||
private String node; | ||
private String nodeAddress; | ||
|
@@ -53,6 +55,8 @@ public class Service { | |
private String address; | ||
private Map<String, String> meta; | ||
private int port; | ||
private long createIndex; | ||
private long modifyIndex; | ||
|
||
/** | ||
* Default constructor | ||
|
@@ -74,6 +78,8 @@ public Service(Service other) { | |
this.address = other.address; | ||
this.meta = other.meta; | ||
this.port = other.port; | ||
this.createIndex = other.createIndex; | ||
this.modifyIndex = other.modifyIndex; | ||
} | ||
|
||
/** | ||
|
@@ -90,6 +96,8 @@ public Service(JsonObject service) { | |
this.address = service.getString(SERVICE_ADDRESS); | ||
this.meta = mapStringString(service.getJsonObject(SERVICE_META)); | ||
this.port = service.getInteger(SERVICE_PORT, 0); | ||
this.createIndex = service.getLong(CREATE_INDEX, 0l); | ||
this.modifyIndex = service.getLong(MODIFY_INDEX, 0l); | ||
} | ||
|
||
/** | ||
|
@@ -123,6 +131,12 @@ public JsonObject toJson() { | |
if (port != 0) { | ||
jsonObject.put(SERVICE_PORT, port); | ||
} | ||
if (createIndex != 0l) { | ||
jsonObject.put(CREATE_INDEX, createIndex); | ||
} | ||
if (modifyIndex != 0l) { | ||
jsonObject.put(MODIFY_INDEX, modifyIndex); | ||
} | ||
return jsonObject; | ||
} | ||
|
||
|
@@ -285,13 +299,60 @@ public Service setPort(int port) { | |
return this; | ||
} | ||
|
||
/** | ||
* Get the internal index value that represents when the entry was created. | ||
* | ||
* @return the internal index value that represents when the entry was created. | ||
*/ | ||
public long getCreateIndex() { | ||
return createIndex; | ||
} | ||
|
||
/** | ||
* Set the internal index value that represents when the entry was created. | ||
* | ||
* @param createIndex the internal index value that represents when the entry was created. | ||
* @return reference to this, for fluency | ||
*/ | ||
public Service setCreateIndex(long createIndex) { | ||
this.createIndex = createIndex; | ||
return this; | ||
} | ||
|
||
/** | ||
* Get the last index that modified this key. | ||
* | ||
* @return the last index that modified this key. | ||
*/ | ||
public long getModifyIndex() { | ||
return modifyIndex; | ||
} | ||
|
||
/** | ||
* Set the last index that modified this key. | ||
* | ||
* @param modifyIndex the last index that modified this key. | ||
* @return reference to this, for fluency | ||
*/ | ||
public Service setModifyIndex(long modifyIndex) { | ||
this.modifyIndex = modifyIndex; | ||
return this; | ||
} | ||
|
||
@Override | ||
public TxnOperationType getOperationType() { | ||
return TxnOperationType.SERVICE; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
Service service = (Service) o; | ||
|
||
if (createIndex != service.createIndex) return false; | ||
if (modifyIndex != service.modifyIndex) return false; | ||
if (port != service.port) return false; | ||
if (node != null ? !node.equals(service.node) : service.node != null) return false; | ||
if (nodeAddress != null ? !nodeAddress.equals(service.nodeAddress) : service.nodeAddress != null) return false; | ||
|
@@ -312,6 +373,8 @@ public int hashCode() { | |
result = 31 * result + (address != null ? address.hashCode() : 0); | ||
result = 31 * result + (meta != null ? meta.hashCode() : 0); | ||
result = 31 * result + port; | ||
result = 31 * result + (int) (createIndex ^ (createIndex >>> 32)); | ||
result = 31 * result + (int) (modifyIndex ^ (modifyIndex >>> 32)); | ||
return result; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,7 @@ | |
package io.vertx.ext.consul; | ||
|
||
/** | ||
* Represents operation in transaction. Key/Value is the only available operation type, | ||
* though other types of operations may be added in future versions of Consul to be mixed with key/value operations | ||
* Represents operation in transaction. The available operation types are KV and Service | ||
* | ||
* @author <a href="mailto:[email protected]">Ruslan Sennov</a> | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
import io.vertx.codegen.annotations.VertxGen; | ||
|
||
/** | ||
* Represents the type of operation in a transaction. KV is the only available operation type, | ||
* though other types of operations may be added in future versions of Consul to be mixed with key/value operations | ||
* Represents the type of operation in a transaction. The available operation types are KV and Service | ||
* | ||
* @author <a href="mailto:[email protected]">Ruslan Sennov</a> | ||
* @see <a href="https://www.consul.io/docs/agent/http/kv.html#txn">/v1/txn</a> endpoint | ||
*/ | ||
@VertxGen | ||
public enum TxnOperationType { | ||
KV | ||
KV, | ||
SERVICE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,7 @@ | |
package io.vertx.ext.consul; | ||
|
||
/** | ||
* Represents result of operation. Key/Value is the only available result type, | ||
* though other types of results may be added in future versions of Consul to be mixed with key/value operations | ||
* Represents result of operation. The available operation types are KV and Service | ||
* | ||
* @author <a href="mailto:[email protected]">Ruslan Sennov</a> | ||
*/ | ||
|
Oops, something went wrong.