File tree Expand file tree Collapse file tree
src/main/java/co/stateful Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,6 +49,14 @@ public interface Lock {
4949 */
5050 String name ();
5151
52+ /**
53+ * Read label (or empty text if lock doesn't exist).
54+ * @return Label of this lock (if the lock exists), or empty string
55+ * @throws IOException If any problem inside
56+ * @since 0.15
57+ */
58+ String label () throws IOException ;
59+
5260 /**
5361 * Lock with label.
5462 * @param label Label to attach
Original file line number Diff line number Diff line change @@ -80,6 +80,23 @@ public String name() {
8080 return this .lck ;
8181 }
8282
83+ @ Override
84+ public String label () throws IOException {
85+ final long start = System .currentTimeMillis ();
86+ final String label = this .front ("label" )
87+ .uri ().queryParam ("name" , this .lck ).back ()
88+ .method (Request .GET )
89+ .fetch ()
90+ .body ();
91+ Logger .info (
92+ this , "label of \" %s\" retrieved in %[ms]s: \" %s\" " ,
93+ this .lck ,
94+ System .currentTimeMillis () - start ,
95+ label
96+ );
97+ return label ;
98+ }
99+
83100 @ Override
84101 public boolean lock (final String label ) throws IOException {
85102 final long start = System .currentTimeMillis ();
Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ public String name() {
5353 return this .getClass ().getName ();
5454 }
5555
56+ @ Override
57+ public String label () {
58+ return "label" ;
59+ }
60+
5661 @ Override
5762 public boolean lock (final String label ) {
5863 return true ;
Original file line number Diff line number Diff line change @@ -75,6 +75,16 @@ public String name() {
7575 return this .origin .name ();
7676 }
7777
78+ @ Override
79+ @ RetryOnFailure
80+ (
81+ verbose = false , attempts = Tv .TWENTY ,
82+ delay = Tv .TWENTY , unit = TimeUnit .SECONDS
83+ )
84+ public String label () throws IOException {
85+ return this .origin .label ();
86+ }
87+
7888 @ Override
7989 @ RetryOnFailure
8090 (
You can’t perform that action at this time.
0 commit comments