public Object getFieldValue(_Fields field) { switch (field) { case HOST_NAME: return getHostName(); case PORT: return Integer.valueOf(getPort()); case IP_ADDRESS: return getIpAddress(); case SERVER_TYPE: return getServerType(); } throw new IllegalStateException(); }
/** * {@inheritDoc} */ @Override public String toString() { return "[" + hostAddr.toString() + ",connId=" + connId + "]"; } }
public boolean equals(final HostConnection other) { return this == other || (connId == other.connId && (hostAddr == other.hostAddr || hostAddr.equals(other.hostAddr)) && (token == other.token || (token != null && token.equals(other.token)))); }
/** * Creates a new socket that will connect to the given host on the given port. * * @param host Remote HostAddress including port * @param params Socket parameters like buffer sizes, keep-alive settings */ public SnappyTSocket(HostAddress host, String clientId, boolean useSSL, boolean blocking, boolean framedWrites, SocketParameters params) throws TTransportException { this(host.resolveHost(), host.getPort(), clientId, useSSL, blocking, framedWrites, params.getReadTimeout(), params); }
case HOST_NAME: if (value == null) { unsetHostName(); setHostName((String)value); unsetPort(); setPort((Integer)value); unsetIpAddress(); setIpAddress((String)value); unsetServerType(); setServerType((ServerType)value);
@Override public void read(org.apache.thrift.protocol.TProtocol prot, getPreferredServer_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.success = new HostAddress(); struct.success.read(iprot); struct.setSuccessIsSet(true); } if (incoming.get(1)) { struct.error = new SnappyException(); struct.error.read(iprot); struct.setErrorIsSet(true); } } }
/** * {@inheritDoc} */ @Override public boolean execute(Object o) { final HostAddress hostAddr = (HostAddress)o; if (this.keepLocators) { if (hostAddr.getServerType().isThriftLocator()) { this.outServers.add(hostAddr); } } if (this.keepServers) { if (hostAddr.getServerType().isThriftSnappy()) { this.outServers.add(hostAddr); } } return true; } }
ni.getPort()).setServerType(serverType)); if (serverTypes.contains(hostAddr.getServerType())) { thriftHosts.add(hostAddr);
ni.getPort()).setServerType(serverType));
public static HostAddress getHostAddress(final String hostNameAndAddress, final int port) { final int slashIndex = hostNameAndAddress.indexOf('/'); if (slashIndex > 0) { final String hostName = hostNameAndAddress.substring(0, slashIndex); final String ipAddress = hostNameAndAddress.substring(slashIndex + 1); if (ipAddress.length() > 0 && !hostName.equals(ipAddress)) { return new HostAddress(hostName, port).setIpAddress(ipAddress); } else { return new HostAddress(hostName, port); } } else if (slashIndex == 0) { return new HostAddress(hostNameAndAddress.substring(1), port); } else { return new HostAddress(hostNameAndAddress, port); } }
@Override public HostAddress deepCopy() { return new HostAddress(this); }
serverSB.append(((HostAddress)s).getHostAddressString()); } else { serverSB.append(s);
/** * Creates a new SSL socket that will connect to the given host on the given * port. * * @param host Remote HostAddress including port * @param params Socket parameters including SSL properties */ public SnappyTSSLSocket(HostAddress host, SocketParameters params) throws TTransportException { this(host.resolveHost(), host.getPort(), params.getReadTimeout(), params); }
case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new HostAddress(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else {
private void refreshAllHosts(List<HostAddress> allHosts) { // refresh the locator list first (keep old but push current to front) final ArrayList<HostAddress> locators = this.locators; final ArrayList<HostAddress> newLocators = new ArrayList<>(locators.size()); for (HostAddress host : allHosts) { if (host.getServerType().isThriftLocator() || locators.contains(host)) { newLocators.add(host); } } for (HostAddress host : locators) { if (!newLocators.contains(host)) { newLocators.add(host); } } this.locators = newLocators; // refresh the new server list // we remove all from the set and re-populate since we would like // to prefer the ones coming as "allServers" with "isServer" flag // correctly set rather than the ones in "secondary-locators" this.controlHostSet.clear(); this.controlHostSet.addAll(newLocators); this.controlHostSet.addAll(allHosts); }
isAdded = addMemberServer(m, ThriftUtils.getHostAddress(bp.getHost(), bp.getPort()) .setServerType(serverType), this.thriftServers, true);
/** * Performs a deep copy on <i>other</i>. */ public getAllServersWithPreferredServer_result(getAllServersWithPreferredServer_result other) { if (other.isSetSuccess()) { List<HostAddress> __this__success = new ArrayList<HostAddress>(other.success.size()); for (HostAddress other_element : other.success) { __this__success.add(new HostAddress(other_element)); } this.success = __this__success; } if (other.isSetError()) { this.error = new SnappyException(other.error); } }
public void validate() throws org.apache.thrift.TException { // check for required fields if (hostName == null) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'hostName' was not present! Struct: " + toString()); } // alas, we cannot check 'port' because it's a primitive and you chose the // non-beans generator. check for sub-struct validity }
final TTransport transport; if (getServerType().isThriftSSL()) { transport = new SnappyTSSLSocket(hostAddr.resolveHost(), hostAddr.getPort(), readTimeout, socketParams); } else { transport = new SnappyTSocket( hostAddr.resolveHost(), hostAddr.getPort(), connArgs.clientID, false, true, ThriftUtils.isThriftSelectorServer(), readTimeout, socketParams);