sergey-chugunov-1985 commented on a change in pull request #70: URL: https://github.com/apache/ignite-3/pull/70#discussion_r598773740
########## File path: modules/network/src/main/java/org/apache/ignite/network/Network.java ########## @@ -0,0 +1,61 @@ +/* + * 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.network; + +import java.util.HashMap; +import java.util.Map; + +/** + * Entry point for network module. + */ +public class Network { + /** Message mappers map, message type -> message mapper. */ + private final Map<Short, MessageMapper> messageMappers = new HashMap<>(); + + /** Message handlers. */ + private final MessageHandlerHolder messageHandlerHolder = new MessageHandlerHolder(); + + /** Cluster factory. */ + private final NetworkClusterFactory clusterFactory; + + /** + * Constructor. + * @param factory Cluster factory. + */ + public Network(NetworkClusterFactory factory) { + clusterFactory = factory; + } + + /** + * Register message mapper by message type. + * @param type Message type. + * @param messageMapper Message mapper. + */ + public void registerMessageMapper(short type, MessageMapper messageMapper) { Review comment: This method along with `start` serve components' life-cycle but on API level we don't have any kind of enforcement which should be called before which. It is assumed that other components call `register` on network to be able to send and receive messages. What do others think if we invert this flow and allow network component to iterate over the list of all other components and obtain message types from them? -- 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]
