alievmirza commented on a change in pull request #112: URL: https://github.com/apache/ignite-3/pull/112#discussion_r623808344
########## File path: modules/core/src/main/java/org/apache/ignite/internal/manager/Event.java ########## @@ -0,0 +1,24 @@ +/* + * 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.manager; + +/** + * Producer event. Review comment: Javadoc is not clear. Let add link to Producer at least ########## File path: modules/core/src/main/java/org/apache/ignite/internal/manager/Producer.java ########## @@ -0,0 +1,70 @@ +/* + * 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.manager; + +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.function.BiPredicate; + +/** + * Interface which can to produce own event. Review comment: ```suggestion * Interface which can produce its own event. ``` ########## File path: modules/core/src/main/java/org/apache/ignite/internal/manager/Producer.java ########## @@ -0,0 +1,70 @@ +/* + * 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.manager; + +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.function.BiPredicate; + +/** + * Interface which can to produce own event. + */ +public abstract class Producer<T extends Event> { + /** All listeners. */ + private ConcurrentHashMap<T, ConcurrentLinkedQueue<BiPredicate<List<Object>, Exception>>> listeners = new ConcurrentHashMap<>(); + + /** + * Registers an event listener. + * When the event predicate return true it would never invoke after, + * otherwise this predicate would receive an event again. + * + * @param evt Event. + * @param closure Closure. + */ + public void listen(T evt, BiPredicate<List<Object>, Exception> closure) { + listeners.computeIfAbsent(evt, evtKey -> new ConcurrentLinkedQueue<>()) + .offer(closure); + } + + /** + * Notifies every listener with subscribed before. Review comment: If I understand that method correctly, there should be `Notifies every listener that was subscribed before.` ########## File path: modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java ########## @@ -181,6 +188,17 @@ public TableManager( }); } + /** + * Compuuses a RAFT group unique name. Review comment: I didn't get Javadoc ########## File path: modules/core/src/main/java/org/apache/ignite/internal/manager/Producer.java ########## @@ -0,0 +1,70 @@ +/* + * 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.manager; + +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.function.BiPredicate; + +/** + * Interface which can to produce own event. + */ +public abstract class Producer<T extends Event> { + /** All listeners. */ + private ConcurrentHashMap<T, ConcurrentLinkedQueue<BiPredicate<List<Object>, Exception>>> listeners = new ConcurrentHashMap<>(); + + /** + * Registers an event listener. + * When the event predicate return true it would never invoke after, Review comment: ```suggestion * When the event predicate returns true it would never invoke after, ``` -- 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. For queries about this service, please contact Infrastructure at: [email protected]
