forked from apache/kudu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[java client] Refactor all server info into a single class, add locality
Having this helps propagate information around the client. RemoteTablet can now answer requests for local servers. This patch also tries to simplify how RemoteTablets are created, as it's getting a bit messy and redundant with the passing of ServerInfos. Change-Id: I33984a437d8c8d07d5db4d16f8da723b3e904189 Reviewed-on: http://gerrit.cloudera.org:8080/4836 Tested-by: Kudu Jenkins Reviewed-by: David Ribeiro Alves <[email protected]>
- Loading branch information
Showing
7 changed files
with
178 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
java/kudu-client/src/main/java/org/apache/kudu/client/ServerInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// 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.kudu.client; | ||
|
||
import org.apache.kudu.annotations.InterfaceAudience; | ||
|
||
/** | ||
* Container class for server information that never changes, like UUID and hostname. | ||
*/ | ||
@InterfaceAudience.Private | ||
public class ServerInfo { | ||
private final String uuid; | ||
private final String hostname; | ||
private final int port; | ||
private final boolean local; | ||
|
||
/** | ||
* Constructor for all the fields. The intent is that there should only be one ServerInfo | ||
* instance per UUID the client is connected to. | ||
* @param uuid server's UUID | ||
* @param hostname server's hostname, only one of them | ||
* @param port server's port | ||
* @param local if the server is hosted on the same machine where this client is running | ||
*/ | ||
public ServerInfo(String uuid, String hostname, int port, boolean local) { | ||
this.uuid = uuid; | ||
this.hostname = hostname; | ||
this.port = port; | ||
this.local = local; | ||
} | ||
|
||
/** | ||
* Returns this server's uuid. | ||
* @return a string that contains this server's uuid | ||
*/ | ||
public String getUuid() { | ||
return uuid; | ||
} | ||
|
||
/** | ||
* Returns this server's hostname. We might get many hostnames from the master for a single | ||
* TS, and this is the one we picked to connect to originally. | ||
* @return a string that contains this server's hostname | ||
*/ | ||
public String getHostname() { | ||
return hostname; | ||
} | ||
|
||
/** | ||
* Returns this server's port. | ||
* @return a port number that this server is bound to | ||
*/ | ||
public int getPort() { | ||
return port; | ||
} | ||
|
||
/** | ||
* Returns if this server is on this client's host. | ||
* @return true if the server is local, else false | ||
*/ | ||
public boolean isLocal() { | ||
return local; | ||
} | ||
} |
Oops, something went wrong.