16
16
import tech .ydb .coordination .CoordinationSession ;
17
17
import tech .ydb .coordination .SemaphoreLease ;
18
18
import tech .ydb .coordination .settings .CoordinationSessionSettings ;
19
+ import tech .ydb .coordination .settings .DescribeSemaphoreMode ;
19
20
import tech .ydb .core .Result ;
20
21
import tech .ydb .jdbc .YdbConnection ;
21
22
@@ -64,12 +65,27 @@ public Optional<SimpleLock> lock(LockConfiguration lockConfiguration) {
64
65
var statusCS = coordinationSession .connect ().join ();
65
66
66
67
if (!statusCS .isSuccess ()) {
67
- logger .info ("Failed creating coordination session [{}]" , coordinationSession );
68
+ logger .warn ("Failed creating coordination session [{}]" , coordinationSession );
68
69
69
70
return Optional .empty ();
70
71
}
71
72
72
- logger .info ("Created coordination node session [{}]" , coordinationSession );
73
+ logger .debug ("Created coordination node session [{}]" , coordinationSession );
74
+
75
+ var describeResult = coordinationSession .describeSemaphore (
76
+ lockConfiguration .getName (),
77
+ DescribeSemaphoreMode .WITH_OWNERS
78
+ ).join ();
79
+
80
+ if (describeResult .isSuccess ()) {
81
+ var describe = describeResult .getValue ();
82
+
83
+ if (!describe .getOwnersList ().isEmpty ()) {
84
+ var describePayload = new String (describe .getOwnersList ().get (0 ).getData (), StandardCharsets .UTF_8 );
85
+
86
+ logger .info ("Received DescribeSemaphore[Name={}, Data={}]" , describe .getName (), describePayload );
87
+ }
88
+ }
73
89
74
90
Result <SemaphoreLease > semaphoreLease = coordinationSession .acquireEphemeralSemaphore (
75
91
lockConfiguration .getName (),
@@ -81,12 +97,12 @@ public Optional<SimpleLock> lock(LockConfiguration lockConfiguration) {
81
97
logger .debug (coordinationSession .toString ());
82
98
83
99
if (semaphoreLease .isSuccess ()) {
84
- logger .info ("Instance[{}] acquired semaphore[SemaphoreName={}]" , instanceInfo ,
100
+ logger .debug ("Instance[{}] acquired semaphore [SemaphoreName={}]" , instanceInfo ,
85
101
semaphoreLease .getValue ().getSemaphoreName ());
86
102
87
103
return Optional .of (new YdbSimpleLock (semaphoreLease .getValue (), instanceInfo , coordinationSession ));
88
104
} else {
89
- logger .info ("Instance[{}] did not acquire semaphore" , instanceInfo );
105
+ logger .debug ("Instance[{}] did not acquire semaphore" , instanceInfo );
90
106
91
107
return Optional .empty ();
92
108
}
@@ -96,7 +112,7 @@ private record YdbSimpleLock(SemaphoreLease semaphoreLease, String metaInfo,
96
112
CoordinationSession coordinationSession ) implements SimpleLock {
97
113
@ Override
98
114
public void unlock () {
99
- logger .info ("Instance[{}] released semaphore[SemaphoreName={}]" , metaInfo , semaphoreLease .getSemaphoreName ());
115
+ logger .info ("Instance[{}] released semaphore [SemaphoreName={}]" , metaInfo , semaphoreLease .getSemaphoreName ());
100
116
101
117
semaphoreLease .release ().join ();
102
118
0 commit comments