@Override public int compareTo(PartitionServerAddress arg0) { int hostComparison = getHostName().compareTo(arg0.getHostName()); if (hostComparison == 0) { return Integer.valueOf(getPortNumber()).compareTo(arg0.getPortNumber()); } return hostComparison; } }
public static FilesystemStatisticsAggregator computeFilesystemStatisticsForRing(Map<Host, Map<String, FilesystemStatisticsAggregator>> filesystemStatistics) { FilesystemStatisticsAggregator result = new FilesystemStatisticsAggregator(); Set<String> hostAndFilesystemRootsAdded = new HashSet<String>(); for (Map.Entry<Host, Map<String, FilesystemStatisticsAggregator>> entry1 : filesystemStatistics.entrySet()) { for (Map.Entry<String, FilesystemStatisticsAggregator> entry2 : entry1.getValue().entrySet()) { String hostAndFilesystemRoot = entry1.getKey().getAddress().getHostName() + entry2.getKey(); if (!hostAndFilesystemRootsAdded.contains(hostAndFilesystemRoot)) { hostAndFilesystemRootsAdded.add(hostAndFilesystemRoot); result.add(entry2.getValue()); } } } return result; }
public static FilesystemStatisticsAggregator computeFilesystemStatisticsForRingGroup( Map<Ring, Map<Host, Map<String, FilesystemStatisticsAggregator>>> filesystemStatistics) { FilesystemStatisticsAggregator result = new FilesystemStatisticsAggregator(); for (Map.Entry<Ring, Map<Host, Map<String, FilesystemStatisticsAggregator>>> entry1 : filesystemStatistics.entrySet()) { for (Map.Entry<Host, Map<String, FilesystemStatisticsAggregator>> entry2 : entry1.getValue().entrySet()) { Set<String> hostAndFilesystemRootsAdded = new HashSet<String>(); for (Map.Entry<String, FilesystemStatisticsAggregator> entry3 : entry2.getValue().entrySet()) { String hostAndFilesystemRoot = entry2.getKey().getAddress().getHostName() + entry3.getKey(); if (!hostAndFilesystemRootsAdded.contains(hostAndFilesystemRoot)) { hostAndFilesystemRootsAdded.add(hostAndFilesystemRoot); result.add(entry3.getValue()); } } } } return result; }
public static ZkHost create(ZooKeeperPlus zk, Coordinator coordinator, String root, PartitionServerAddress partitionServerAddress, DataLocationChangeListener dataLocationChangeListener, List<String> flags) throws KeeperException, InterruptedException { String path = ZkPath.append(root, Long.toString(Math.abs(UUID.randomUUID().getLeastSignificantBits()))); if (LOG.isTraceEnabled()) { LOG.trace("Creating ZkHost " + partitionServerAddress + " at " + path); } HostMetadata initialMetadata = new HostMetadata(); initialMetadata.set_flags(Hosts.joinHostFlags(flags)); initialMetadata.set_host_name(partitionServerAddress.getHostName()); initialMetadata.set_port_number(partitionServerAddress.getPortNumber()); HostAssignmentsMetadata initialAssignments = new HostAssignmentsMetadata(); initialAssignments.set_domains(new HashMap<Integer, HostDomainMetadata>()); return new ZkHost(zk, coordinator, path, dataLocationChangeListener, true, initialMetadata, initialAssignments); }
private void connect() throws IOException { if (LOG.isTraceEnabled()) { LOG.trace("Trying to connect to " + host.getAddress()); } // Use connection timeout to connect socket = new TSocket(host.getAddress().getHostName(), host.getAddress().getPortNumber(), establishConnectionTimeoutMs); transport = new TFramedTransport(socket); try { transport.open(); // Set socket timeout to regular mode setSocketTimeout(queryTimeoutMs); } catch (TTransportException e) { LOG.error("Failed to establish connection to host " + host.getAddress(), e); disconnect(); throw new IOException("Failed to establish connection to host " + host.getAddress(), e); } TProtocol proto = new TCompactProtocol(transport); client = new PartitionServer.Client(proto); if (LOG.isTraceEnabled()) { LOG.trace("Connection to " + host.getAddress() + " opened."); } }
@Override protected String formatCore(NotificationFormatter formatter) { return formatter.getWebUiLink(HostController.getHostUrl(ringGroup, ring, host), host.getAddress().getHostName() + ":" + host.getAddress().getPortNumber()) + " is " + hostState; } }
@Override public void run() { TSocket socket = null; TFramedTransport transport = null; try { socket = new TSocket(host.getAddress().getHostName(), host.getAddress().getPortNumber(), 0); transport = new TFramedTransport(socket); transport.open(); TProtocol proto = new TCompactProtocol(transport); com.liveramp.hank.generated.PartitionServer.Client client = new com.liveramp.hank.generated.PartitionServer.Client(proto); // Perform queries for (int i = 0; i < NUM_WARMUP_QUERIES_PER_THREAD; i++) { client.get(0, ByteBuffer.wrap(new byte[0])); } } catch (TException e) { LOG.error("Failed to warm up data server", e); throw new RuntimeException("Failed to warm up data server", e); } finally { if (transport != null) { transport.close(); } if (socket != null) { socket.close(); } } } }
private static boolean allPartitionsUpToDate(Host host, Collection<DomainAndVersion> domainVersions, boolean allowMoreRecentDomainVersions) throws IOException { // Check that each domain of the given domain group version is up to date on this host for (DomainAndVersion domainAndVersion : domainVersions) { Domain domain = domainAndVersion.getDomain(); HostDomain hostDomain = host.getHostDomain(domain); if (hostDomain != null) { for (HostDomainPartition partition : hostDomain.getPartitions()) { // Ignore deletable partitions if (!partition.isDeletable()) { // If the partition is not currently at the given domain group version, the host is not up-to-date if (partition.getCurrentDomainVersion() == null || (!allowMoreRecentDomainVersions && partition.getCurrentDomainVersion() != domainAndVersion.getVersionNumber()) || (allowMoreRecentDomainVersions && (partition.getCurrentDomainVersion() < domainAndVersion.getVersionNumber()))) { LOG.info("Host " + host.getAddress().getHostName() + " is not up to date for domain " + domain.getName() + " and version " + domainAndVersion.getVersionNumber()); LOG.info("Host " + host.getAddress().getHostName() + " has a partition on domain " + domain.getName() + " at version " + partition.getCurrentDomainVersion()); return false; } } } } } return true; }