vldpyatkov commented on a change in pull request #344:
URL: https://github.com/apache/ignite-3/pull/344#discussion_r747775338



##########
File path: 
modules/runner/src/integrationTest/java/org/apache/ignite/internal/test/WatchListenerInhibitor.java
##########
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+import java.util.ArrayList;
+import java.util.Optional;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+/**
+ * Listener which wraps another one to inhibit events.
+ */
+public class WatchListenerInhibitor implements WatchListener {
+    /** Inhibited events. */
+    private final ArrayList<WatchEvent> inhibitEvents = new ArrayList<>();
+
+    /** Inhibit flag. */
+    private boolean inhibit = false;
+
+    /** Wrapped listener. */
+    private WatchListener realListener;
+
+    /**
+     * Creates the specific listener which can inhibit events for real 
metastorage listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener 
inhibitor.
+     */
+    public static WatchListenerInhibitor metastorageEventsInhibitor(Ignite 
ignite)
+            throws Exception {
+        //TODO: IGNITE-15723 After a component factory will be implemented, 
need to got rid of reflection here.
+        MetaStorageManager metaMngr = (MetaStorageManager) 
ReflectionUtils.tryToReadFieldValue(
+                IgniteImpl.class,
+                "metaStorageMgr",
+                (IgniteImpl) ignite
+        ).get();
+    
+        assertNotNull(metaMngr);
+    
+        WatchAggregator aggregator = (WatchAggregator) 
ReflectionUtils.tryToReadFieldValue(

Review comment:
       We have the issue IGNITE-15723 to resolve this reference without any 
reflection mechanism (it is written couple line upper).
   But I only move this code to use it into various tests, but the code of 
Inhibitor have been existing for a month.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to