phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshelser <...@git.apache.org>
Subject [GitHub] phoenix pull request #236: PHOENIX-3654 Load Balancer for thin client
Date Mon, 24 Jul 2017 15:33:10 GMT
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/236#discussion_r129068996
  
    --- Diff: phoenix-load-balancer/src/main/java/org/apache/phoenix/queryserver/register/ZookeeperRegistry.java
---
    @@ -0,0 +1,72 @@
    +/**
    + *
    + * 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.phoenix.queryserver.register;
    +
    +
    +import com.google.common.net.HostAndPort;
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.curator.framework.CuratorFramework;
    +import org.apache.curator.framework.CuratorFrameworkFactory;
    +import org.apache.curator.retry.ExponentialBackoffRetry;
    +import org.apache.curator.utils.CloseableUtils;
    +import org.apache.phoenix.loadbalancer.service.LoadBalanceZookeeperConf;
    +import org.apache.phoenix.queryserver.server.QueryServer;
    +import org.apache.zookeeper.CreateMode;
    +import org.apache.zookeeper.data.Stat;
    +
    +import java.nio.charset.StandardCharsets;
    +
    +
    +public class ZookeeperRegistry implements Registry {
    +
    +    protected static final Log LOG = LogFactory.getLog(QueryServer.class);
    +    private CuratorFramework client;
    +
    +    public ZookeeperRegistry(){}
    +
    +    @Override
    +    public  void registerServer(LoadBalanceZookeeperConf configuration, int pqsPort,
    +                                String zookeeperConnectString, String pqsHost)
    +            throws Exception {
    +
    +        this.client = CuratorFrameworkFactory.newClient(zookeeperConnectString,
    +                new ExponentialBackoffRetry(1000,10));
    +        this.client.start();
    +        HostAndPort hostAndPort = HostAndPort.fromParts(pqsHost,pqsPort);
    +        String path = configuration.getFullPathToNode(hostAndPort);
    +        String node = hostAndPort.toString();
    +        this.client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(path
    +                ,node.getBytes(StandardCharsets.UTF_8));
    +        Stat stat = this.client.setACL().withACL(configuration.getAcls()).forPath(path);
    +        if (stat != null) {
    +            LOG.info(" node created with right ACL");
    +        }
    +        else {
    +            LOG.error("could not create node with right ACL. So, system would exit now.");
    +            System.exit(-1);
    --- End diff --
    
    Calling `System.exit(-1)` is pretty brutal for anyone trying to integrate with your software
:)
    
    Throwing a RuntimeException would be nicer.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message