qqu0127 commented on code in PR #2550: URL: https://github.com/apache/helix/pull/2550#discussion_r1255403758
########## meta-client/src/main/java/org/apache/helix/metaclient/exception/MetaClientNodeExistsException.java: ########## @@ -0,0 +1,38 @@ +package org.apache.helix.metaclient.exception; + +/* + * 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 final class MetaClientNodeExistsException extends MetaClientException { + public MetaClientNodeExistsException() { + super(); + } + + public MetaClientNodeExistsException(String message, Throwable cause) { + super(message, cause); + } + + public MetaClientNodeExistsException(String message) { + super(message); + } + + public MetaClientNodeExistsException(Throwable cause) { + super(cause); + } Review Comment: Do you actually need these? ########## meta-client/src/main/java/org/apache/helix/metaclient/recipes/lock/DistributedSemaphore.java: ########## @@ -75,9 +76,12 @@ public DistributedSemaphore(MetaClientInterface<DataRecord> client) { _metaClient = client; try { _metaClient.connect(); - // TODO: Differentiate exception catch between already connected and already closed. } catch (IllegalStateException e) { - // Ignore as it either has already been connected or already been closed. + if (e.getMessage().contains("connect() has already been called")) { + LOG.info("Client already connected"); Review Comment: +1 to xyuanlu's point Alternatively, you can make `_metaClient.connect()` idempotent, all following calls after initial connect() are no-op. Users won't have to worry about checking isConnected. This might lead to some behavior changes though. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
