junkaixue commented on code in PR #2883: URL: https://github.com/apache/helix/pull/2883#discussion_r1719078940
########## helix-gateway/src/main/java/org/apache/helix/gateway/HelixGatewayMain.java: ########## @@ -38,16 +37,11 @@ private HelixGatewayMain() { public static void main(String[] args) throws InterruptedException, IOException { // Create a new server to listen on port 50051 - GatewayServiceManager manager = new GatewayServiceManager(); - Server server = new HelixGatewayGrpcServerBuilder().setPort(50051) - .setGrpcService((HelixGatewayServiceGrpcService)manager.getHelixGatewayServiceProcessor()) - .build(); - - server.start(); - System.out.println("Server started, listening on " + server.getPort()); + GatewayServiceChannelConfig.GatewayServiceProcessorConfigBuilder builder = new GatewayServiceChannelConfig.GatewayServiceProcessorConfigBuilder(); + GatewayServiceManager manager = new GatewayServiceManager(args[0], + builder.setGrpcServerPort(50051).build()); Review Comment: Let's get this as a pass in argument? ########## helix-gateway/src/main/java/org/apache/helix/gateway/api/constant/GatewayServiceDefaultConfig.java: ########## @@ -0,0 +1,28 @@ +package org.apache.helix.gateway.api.constant; + +/* + * 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. + */ + +public class GatewayServiceDefaultConfig { Review Comment: Shall we call it constant or keys instead of configs. ########## helix-gateway/src/main/java/org/apache/helix/gateway/channel/GatewayServiceChannelConfig.java: ########## @@ -0,0 +1,173 @@ +package org.apache.helix.gateway.channel; + +/* + * 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. + */ + + +import static org.apache.helix.gateway.api.constant.GatewayServiceDefaultConfig.*; + +public class GatewayServiceChannelConfig { + public enum ChannelType { + GRPC_SERVER, POLL_GRPC, SHARED_FILE Review Comment: use the new formatter of Helix and make it one per line. ########## helix-gateway/src/main/java/org/apache/helix/gateway/channel/HelixGatewayServiceChannelFactory.java: ########## @@ -0,0 +1,42 @@ +package org.apache.helix.gateway.channel; + +/* + * 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. + */ + +import org.apache.commons.lang3.NotImplementedException; +import org.apache.helix.gateway.api.service.HelixGatewayServiceChannel; +import org.apache.helix.gateway.service.GatewayServiceManager; + + +public class HelixGatewayServiceChannelFactory { + + public static HelixGatewayServiceChannel createServiceChannel(GatewayServiceChannelConfig config, Review Comment: Do we have combination of it as input / output? ########## helix-gateway/src/main/java/org/apache/helix/gateway/channel/GatewayServiceChannelConfig.java: ########## @@ -0,0 +1,173 @@ +package org.apache.helix.gateway.channel; + +/* + * 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. + */ + + +import static org.apache.helix.gateway.api.constant.GatewayServiceDefaultConfig.*; + +public class GatewayServiceChannelConfig { + public enum ChannelType { + GRPC_SERVER, POLL_GRPC, SHARED_FILE + } + + // service configs + // channel type for participant liveness detection + private ChannelType _participantConnectionChannelType; + // channel for sending and receiving shard state transition request and shard state response + private ChannelType _shardStatenChannelType; + + // grpc server configs + private final int _grpcServerPort; + private final int _serverHeartBeatInterval; + private final int _maxAllowedClientHeartBeatInterval; + private final int _clientTimeout; + private final boolean _enableReflectionService; + + // poll mode config + private final int _pollIntervalSec; + // TODO: configs for pull mode grpc client + + // TODO: configs for pull mode with file + + // getters + public ChannelType getParticipantConnectionChannelType() { + return _participantConnectionChannelType; + } + + public ChannelType getShardStatenChannelType() { + return _shardStatenChannelType; + } + + public int getGrpcServerPort() { + return _grpcServerPort; + } + + public int getServerHeartBeatInterval() { + return _serverHeartBeatInterval; + } + + public int getMaxAllowedClientHeartBeatInterval() { + return _maxAllowedClientHeartBeatInterval; + } + + public int getClientTimeout() { + return _clientTimeout; + } + + public boolean getEnableReflectionService() { + return _enableReflectionService; + } + + public int getPollIntervalSec() { + return _pollIntervalSec; + } + + public GatewayServiceChannelConfig(int grpcServerPort, ChannelType participantConnectionChannelType, Review Comment: If you are using builder, why we make it public? ########## helix-gateway/src/main/java/org/apache/helix/gateway/channel/GatewayServiceChannelConfig.java: ########## @@ -0,0 +1,173 @@ +package org.apache.helix.gateway.channel; + +/* + * 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. + */ + + +import static org.apache.helix.gateway.api.constant.GatewayServiceDefaultConfig.*; + +public class GatewayServiceChannelConfig { + public enum ChannelType { + GRPC_SERVER, POLL_GRPC, SHARED_FILE Review Comment: Also let's define right axis of the these types: grpc as long lived (push), grpc as short lived (poll), file based (poll). ########## helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java: ########## @@ -127,8 +132,13 @@ public void run() { } } - public HelixGatewayServiceChannel getHelixGatewayServiceProcessor() { - return _gatewayServiceChannel; + + public void startService() throws IOException { + _gatewayServiceChannel.start(); + } + + public void stopService() { + _gatewayServiceChannel.stop(); Review Comment: You just stop the channel. processor needs to be stopped as well. And clean the map. -- 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: reviews-unsubscr...@helix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org For additional commands, e-mail: reviews-h...@helix.apache.org