Skip to content

Commit cf0a916

Browse files
authored
IGNITE-26904 Added data center ID to the ClusterNodeView (#12490)
1 parent c40ff36 commit cf0a916

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

modules/core/src/main/java/org/apache/ignite/spi/systemview/view/ClusterNodeView.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,26 @@ public String version() {
9595
* @return {@code True} if node local.
9696
* @see ClusterNode#isLocal()
9797
*/
98+
@Order(7)
9899
public boolean isLocal() {
99100
return n.isLocal();
100101
}
101102

102103
/**
103104
* @return {@code True} if node is client.
104-
* @see ClusterNode#isClient() ()
105+
* @see ClusterNode#isClient()
105106
*/
106107
@Order(3)
107108
public boolean isClient() {
108109
return n.isClient();
109110
}
111+
112+
/**
113+
* @return Data center ID.
114+
* @see ClusterNode#dataCenterId()
115+
*/
116+
@Order(8)
117+
public String dataCenterId() {
118+
return n.dataCenterId();
119+
}
110120
}

modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewSelfTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,14 @@
143143
import org.apache.ignite.spi.systemview.view.datastructures.SemaphoreView;
144144
import org.apache.ignite.spi.systemview.view.datastructures.SetView;
145145
import org.apache.ignite.testframework.GridTestUtils;
146+
import org.apache.ignite.testframework.junits.WithSystemProperty;
146147
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
147148
import org.apache.ignite.transactions.Transaction;
148149
import org.jetbrains.annotations.NotNull;
149150
import org.jetbrains.annotations.Nullable;
150151
import org.junit.Test;
151152

153+
import static org.apache.ignite.IgniteSystemProperties.IGNITE_DATA_CENTER_ID;
152154
import static org.apache.ignite.configuration.AtomicConfiguration.DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE;
153155
import static org.apache.ignite.events.EventType.EVT_CONSISTENCY_VIOLATION;
154156
import static org.apache.ignite.internal.IgniteKernal.CFG_VIEW;
@@ -829,6 +831,7 @@ private void checkContinuousQueryView(IgniteEx g, SystemView<ContinuousQueryView
829831

830832
/** */
831833
@Test
834+
@WithSystemProperty(key = IGNITE_DATA_CENTER_ID, value = "DC0")
832835
public void testNodes() throws Exception {
833836
try (IgniteEx g1 = startGrid(0)) {
834837
SystemView<ClusterNodeView> views = g1.context().systemView().view(NODES_SYS_VIEW);
@@ -840,7 +843,6 @@ public void testNodes() throws Exception {
840843

841844
checkViewsState(views, g1.localNode(), g2.localNode());
842845
checkViewsState(g2.context().systemView().view(NODES_SYS_VIEW), g2.localNode(), g1.localNode());
843-
844846
}
845847

846848
assertEquals(1, views.size());
@@ -962,6 +964,8 @@ private void checkNodeView(ClusterNodeView view, ClusterNode node, boolean isLoc
962964
assertEquals(node.version().toString(), view.version());
963965
assertEquals(isLoc, view.isLocal());
964966
assertEquals(node.isClient(), view.isClient());
967+
assertEquals(node.dataCenterId(), view.dataCenterId());
968+
assertEquals("DC0", view.dataCenterId());
965969
}
966970

967971
/** */

0 commit comments

Comments
 (0)