Package com.google.common.net

Examples of com.google.common.net.HostAndPort


        }

        if (builder == null && LettuceStrings.isNotEmpty(uri.getAuthority())) {
            String[] hosts = uri.getAuthority().split("\\,");
            for (String host : hosts) {
                HostAndPort hostAndPort = HostAndPort.fromString(host);
                if (builder == null) {
                    if (hostAndPort.hasPort()) {
                        builder = RedisURI.Builder.sentinel(hostAndPort.getHostText(), hostAndPort.getPort(), masterId);
                    } else {
                        builder = RedisURI.Builder.sentinel(hostAndPort.getHostText(), masterId);
                    }
                } else {
                    if (hostAndPort.hasPort()) {
                        builder.withSentinel(hostAndPort.getHostText(), hostAndPort.getPort());
                    } else {
                        builder.withSentinel(hostAndPort.getHostText());
                    }
                }
            }

        }
View Full Code Here


        RedisChannelWriter<K, V> channelWriter = null;

        if (commandToSend instanceof ClusterCommand) {
            ClusterCommand<K, V, T> clusterCommand = (ClusterCommand<K, V, T>) commandToSend;
            if (!clusterCommand.isDone() && clusterCommand.isMoved()) {
                HostAndPort moveTarget = getMoveTarget(clusterCommand.getError());

                RedisAsyncConnectionImpl<K, V> connection = clusterConnectionProvider.getConnection(
                        ClusterConnectionProvider.Intent.WRITE, moveTarget.getHostText(), moveTarget.getPort());
                channelWriter = connection.getChannelWriter();
            }

        }
View Full Code Here

        String nodeId = iterator.next();
        boolean connected = false;
        RedisURI uri = null;

        HostAndPort hostAndPort = HostAndPort.fromString(iterator.next());

        if (LettuceStrings.isNotEmpty(hostAndPort.getHostText())) {
            uri = RedisURI.Builder.redis(hostAndPort.getHostText(), hostAndPort.getPort()).build();
        }

        String flags = iterator.next();
        List<String> flagStrings = Lists.newArrayList(Splitter.on(',').trimResults().split(flags).iterator());
View Full Code Here

    private static ClusterSlotRange parseRange(List<?> range) {
        Iterator<?> iterator = range.iterator();

        int from = Ints.checkedCast(getLongFromIterator(iterator, 0));
        int to = Ints.checkedCast(getLongFromIterator(iterator, 0));
        HostAndPort master = null;

        List<HostAndPort> slaves = Lists.newArrayList();
        if (iterator.hasNext()) {
            master = getHostAndPort(iterator);
        }

        while (iterator.hasNext()) {
            HostAndPort slave = getHostAndPort(iterator);
            if (slave != null) {
                slaves.add(slave);
            }
        }
View Full Code Here

            }

            Iterator<?> hostAndPortIterator = hostAndPortList.iterator();
            String host = (String) hostAndPortIterator.next();
            int port = Ints.checkedCast(getLongFromIterator(hostAndPortIterator, 0));
            HostAndPort hostAndPort = HostAndPort.fromParts(host, port);

            return hostAndPort;

        }
        return null;
View Full Code Here

            case "discovery":
                return injector.getInstance(DiscoveryLocatedHiveCluster.class);
            case "thrift":
                checkArgument(uri.getHost() != null, "metastoreUri host is missing: %s", uri);
                checkArgument(uri.getPort() != -1, "metastoreUri port is missing: %s", uri);
                HostAndPort address = HostAndPort.fromParts(uri.getHost(), uri.getPort());
                return new StaticHiveCluster(address, injector.getInstance(HiveMetastoreClientFactory.class));
        }
        throw new IllegalArgumentException("unsupported metastoreUri: " + uri);
    }
View Full Code Here

        s = s.toLowerCase();
        if (s.startsWith("http://") || s.startsWith("https://")) {
            return URI.create(s);
        }

        HostAndPort host = HostAndPort.fromString(s);
        try {
            return new URI("http", null, host.getHostText(), host.getPortOrDefault(80), null, null, null);
        }
        catch (URISyntaxException e) {
            throw new IllegalArgumentException(e);
        }
    }
View Full Code Here

    }

    protected <T> ListenableFuture<T> createClient(Class<T> clientClass, int serverPort, final Duration connectDelay)
            throws TTransportException, InterruptedException, ExecutionException
    {
        HostAndPort address = HostAndPort.fromParts("localhost", serverPort);
        ThriftClientConfig config = new ThriftClientConfig().setConnectTimeout(new Duration(1, TimeUnit.SECONDS))
                                                            .setReadTimeout(new Duration(1, TimeUnit.SECONDS))
                                                            .setWriteTimeout(new Duration(1, TimeUnit.SECONDS));
        FramedClientConnector connector = new FramedClientConnector(address) {
            @Override
View Full Code Here

    // Called by FXMLLoader
    public void initialize() {
        server.textProperty().addListener((observableValue, prev, current) -> connectBtn.setDisable(current.trim().isEmpty()));
        defaultTitle = titleLabel.getText();
        // Restore the server used last time, minus the port part if it was the default.
        HostAndPort lastServer = Settings.getLastServer();
        if (lastServer != null)
            server.setText(lastServer.getPort() == PayFileClient.PORT ? lastServer.getHostText() : lastServer.toString());
    }
View Full Code Here

            server.setText(lastServer.getPort() == PayFileClient.PORT ? lastServer.getHostText() : lastServer.toString());
    }

    public void connect(ActionEvent event) {
        final String serverName = server.getText().trim();
        HostAndPort hostPort = verifyServerName(serverName);
        if (hostPort == null)
            return;
        connectBtn.setDisable(true);

        maybeSettleLastServer(hostPort).thenRun(() -> {
View Full Code Here

TOP

Related Classes of com.google.common.net.HostAndPort

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.