com.twitter.thrift.Status Java Examples
The following examples show how to use
com.twitter.thrift.Status.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NameServerSet.java From distributedlog with Apache License 2.0 | 6 votes |
private ServiceInstance endpointAddressToServiceInstance(Address endpointAddress) { if (endpointAddress instanceof Address.Inet) { InetSocketAddress inetSocketAddress = ((Address.Inet) endpointAddress).addr(); Endpoint endpoint = new Endpoint(inetSocketAddress.getHostString(), inetSocketAddress.getPort()); HashMap<String, Endpoint> map = new HashMap<String, Endpoint>(); map.put("thrift", endpoint); return new ServiceInstance( endpoint, map, Status.ALIVE); } else { logger.error("We expect InetSocketAddress while the resolved address {} was {}", endpointAddress, endpointAddress.getClass()); throw new UnsupportedOperationException("invalid endpoint address: " + endpointAddress); } }
Example #2
Source File: NameServerSet.java From distributedlog with Apache License 2.0 | 6 votes |
private ServiceInstance endpointAddressToServiceInstance(Address endpointAddress) { if (endpointAddress instanceof Address.Inet) { InetSocketAddress inetSocketAddress = ((Address.Inet) endpointAddress).addr(); Endpoint endpoint = new Endpoint(inetSocketAddress.getHostString(), inetSocketAddress.getPort()); HashMap<String, Endpoint> map = new HashMap<String, Endpoint>(); map.put("thrift", endpoint); return new ServiceInstance( endpoint, map, Status.ALIVE); } else { logger.error("We expect InetSocketAddress while the resolved address {} was {}", endpointAddress, endpointAddress.getClass()); throw new UnsupportedOperationException("invalid endpoint address: " + endpointAddress); } }
Example #3
Source File: ConfigFileServerSet.java From pinlater with Apache License 2.0 | 5 votes |
protected static ImmutableSet<ServiceInstance> readServerSet(byte[] fileContent) throws IOException { ImmutableSet.Builder<ServiceInstance> builder = new ImmutableSet.Builder<ServiceInstance>(); InputStream stream = new ByteArrayInputStream(fileContent); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); while (true) { String line = reader.readLine(); if (line == null) { // EOF. break; } else if (line.isEmpty()) { // Skip empty lines. continue; } // We expect each line to be of the form "hostname:port". Note that host names can // contain ':' themselves (e.g. ipv6 addresses). int index = line.lastIndexOf(':'); Preconditions.checkArgument(index > 0 && index < line.length() - 1); String host = line.substring(0, index); int port = Integer.parseInt(line.substring(index + 1)); builder.add(new ServiceInstance( new Endpoint(host, port), // endpoint Collections.<String, Endpoint>emptyMap(), // additional endpoints Status.ALIVE)); // status } return builder.build(); }
Example #4
Source File: ConfigFileServerSet.java From pinlater with Apache License 2.0 | 4 votes |
@Override public EndpointStatus join( InetSocketAddress endpoint, Map<String, InetSocketAddress> additionalEndpoints, Status status) throws Group.JoinException, InterruptedException { throw new UnsupportedOperationException("ConfigFileServerSet does not support join()"); }
Example #5
Source File: NameServerSet.java From distributedlog with Apache License 2.0 | 3 votes |
/** * Attempts to join a server set for this logical service group. * * @param endpoint the primary service endpoint * @param additionalEndpoints and additional endpoints keyed by their logical name * @param status the current service status * @return an EndpointStatus object that allows the endpoint to adjust its status * @throws Group.JoinException if there was a problem joining the server set * @throws InterruptedException if interrupted while waiting to join the server set * @deprecated The status field is deprecated. Please use {@link #join(java.net.InetSocketAddress, java.util.Map)} */ @Override public EndpointStatus join(InetSocketAddress endpoint, Map<String, InetSocketAddress> additionalEndpoints, Status status) throws Group.JoinException, InterruptedException { throw new UnsupportedOperationException("NameServerSet does not support join"); }
Example #6
Source File: NameServerSet.java From distributedlog with Apache License 2.0 | 2 votes |
/** * Attempts to join a server set for this logical service group. * * @param endpoint the primary service endpoint * @param additionalEndpoints and additional endpoints keyed by their logical name * @param status the current service status * @return an EndpointStatus object that allows the endpoint to adjust its status * @throws Group.JoinException if there was a problem joining the server set * @throws InterruptedException if interrupted while waiting to join the server set * @deprecated The status field is deprecated. Please use {@link #join(java.net.InetSocketAddress, java.util.Map)} */ @Override public EndpointStatus join(InetSocketAddress endpoint, Map<String, InetSocketAddress> additionalEndpoints, Status status) throws Group.JoinException, InterruptedException { throw new UnsupportedOperationException("NameServerSet does not support join"); }